Import Upstream version 1.0.14

This commit is contained in:
Guus Sliepen 2019-08-26 13:44:40 +02:00
parent 3f0ae998e8
commit d906f6f9b0
50 changed files with 1593 additions and 753 deletions

View file

@ -1,7 +1,7 @@
/*
dropin.c -- a set of drop-in replacements for libc functions
Copyright (C) 2000-2005 Ivo Timmermans,
2000-2009 Guus Sliepen <guus@tinc-vpn.org>
2000-2011 Guus Sliepen <guus@tinc-vpn.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -163,3 +163,11 @@ int gettimeofday(struct timeval *tv, void *tz) {
return 0;
}
#endif
#ifndef HAVE_USLEEP
int usleep(long usec) {
struct timeval tv = {usec / 1000000, (usec / 1000) % 1000};
select(0, NULL, NULL, NULL, &tv);
return 0;
}
#endif

View file

@ -1,7 +1,7 @@
/*
dropin.h -- header file for dropin.c
Copyright (C) 2000-2005 Ivo Timmermans,
2000-2009 Guus Sliepen <guus@tinc-vpn.org>
2000-2011 Guus Sliepen <guus@tinc-vpn.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -41,4 +41,8 @@ extern int vasprintf(char **, const char *, va_list ap);
extern int gettimeofday(struct timeval *, void *);
#endif
#ifndef HAVE_USLEEP
extern int usleep(long);
#endif
#endif /* __DROPIN_H__ */

View file

@ -44,6 +44,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <stdio.h>
#ifdef HAVE_STRING_H
#include <string.h>
#endif
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
Library, but also included in many other GNU distributions. Compiling
@ -688,16 +692,18 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
else
{
if (opterr)
if (argv[optind - 1][1] == '-')
/* --option */
fprintf (stderr,
"%s: option `--%s' doesn't allow an argument\n",
argv[0], pfound->name);
else
/* +option or -option */
fprintf (stderr,
"%s: option `%c%s' doesn't allow an argument\n",
argv[0], argv[optind - 1][0], pfound->name);
{
if (argv[optind - 1][1] == '-')
/* --option */
fprintf (stderr,
"%s: option `--%s' doesn't allow an argument\n",
argv[0], pfound->name);
else
/* +option or -option */
fprintf (stderr,
"%s: option `%c%s' doesn't allow an argument\n",
argv[0], argv[optind - 1][0], pfound->name);
}
nextchar += strlen (nextchar);

View file

@ -23,6 +23,10 @@
# include "config.h"
#endif
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#undef __ptr_t
#if defined __cplusplus || (defined __STDC__ && __STDC__)
# define __ptr_t void *
@ -107,8 +111,8 @@ static int
memcmp_bytes (a, b)
op_t a, b;
{
long int srcp1 = (long int) &a;
long int srcp2 = (long int) &b;
intptr_t srcp1 = (intptr_t) &a;
intptr_t srcp2 = (intptr_t) &b;
op_t a0, b0;
do
@ -123,7 +127,7 @@ memcmp_bytes (a, b)
}
#endif
static int memcmp_common_alignment __P((long, long, size_t));
static int memcmp_common_alignment __P((intptr_t, intptr_t, size_t));
/* memcmp_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN `op_t'
objects (not LEN bytes!). Both SRCP1 and SRCP2 should be aligned for
@ -133,8 +137,8 @@ __inline
#endif
static int
memcmp_common_alignment (srcp1, srcp2, len)
long int srcp1;
long int srcp2;
intptr_t srcp1;
intptr_t srcp2;
size_t len;
{
op_t a0, a1;
@ -213,7 +217,7 @@ memcmp_common_alignment (srcp1, srcp2, len)
return 0;
}
static int memcmp_not_common_alignment __P((long, long, size_t));
static int memcmp_not_common_alignment __P((intptr_t, intptr_t, size_t));
/* memcmp_not_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN
`op_t' objects (not LEN bytes!). SRCP2 should be aligned for memory
@ -223,8 +227,8 @@ __inline
#endif
static int
memcmp_not_common_alignment (srcp1, srcp2, len)
long int srcp1;
long int srcp2;
intptr_t srcp1;
intptr_t srcp2;
size_t len;
{
op_t a0, a1, a2, a3;
@ -332,8 +336,8 @@ rpl_memcmp (s1, s2, len)
{
op_t a0;
op_t b0;
long int srcp1 = (long int) s1;
long int srcp2 = (long int) s2;
intptr_t srcp1 = (intptr_t) s1;
intptr_t srcp2 = (intptr_t) s2;
op_t res;
if (len >= OP_T_THRES)

View file

@ -41,7 +41,7 @@ pid_t read_pid (char *pidfile)
if (!(f=fopen(pidfile,"r")))
return 0;
if(fscanf(f,"%ld", &pid) != 1)
if(fscanf(f,"%20ld", &pid) != 1)
pid = 0;
fclose(f);
return pid;