diff options
Diffstat (limited to 'libc/misc')
29 files changed, 134 insertions, 141 deletions
diff --git a/libc/misc/dirent/closedir.c b/libc/misc/dirent/closedir.c index 57600ab69..25c424566 100644 --- a/libc/misc/dirent/closedir.c +++ b/libc/misc/dirent/closedir.c @@ -19,14 +19,10 @@ int closedir(DIR * dir) __set_errno(EBADF); return -1; } -#ifdef __UCLIBC_HAS_THREADS__ __pthread_mutex_lock(&(dir->dd_lock)); -#endif fd = dir->dd_fd; dir->dd_fd = -1; -#ifdef __UCLIBC_HAS_THREADS__ __pthread_mutex_unlock(&(dir->dd_lock)); -#endif free(dir->dd_buf); free(dir); return __close(fd); diff --git a/libc/misc/dirent/opendir.c b/libc/misc/dirent/opendir.c index 9f5f75e3f..fd14213a5 100644 --- a/libc/misc/dirent/opendir.c +++ b/libc/misc/dirent/opendir.c @@ -51,8 +51,6 @@ DIR *opendir(const char *name) return NULL; } ptr->dd_buf = buf; -#ifdef __UCLIBC_HAS_THREADS__ __pthread_mutex_init(&(ptr->dd_lock), NULL); -#endif return ptr; } diff --git a/libc/misc/dirent/readdir.c b/libc/misc/dirent/readdir.c index 1f196e1e7..68a465fc8 100644 --- a/libc/misc/dirent/readdir.c +++ b/libc/misc/dirent/readdir.c @@ -16,9 +16,7 @@ struct dirent *readdir(DIR * dir) return NULL; } -#ifdef __UCLIBC_HAS_THREADS__ __pthread_mutex_lock(&(dir->dd_lock)); -#endif do { if (dir->dd_size <= dir->dd_nextloc) { @@ -44,8 +42,6 @@ struct dirent *readdir(DIR * dir) } while (de->d_ino == 0); all_done: -#ifdef __UCLIBC_HAS_THREADS__ __pthread_mutex_unlock(&(dir->dd_lock)); -#endif return de; } diff --git a/libc/misc/dirent/readdir64.c b/libc/misc/dirent/readdir64.c index f798c6fbb..8d22a314e 100644 --- a/libc/misc/dirent/readdir64.c +++ b/libc/misc/dirent/readdir64.c @@ -31,9 +31,7 @@ struct dirent64 *readdir64(DIR * dir) return NULL; } -#ifdef __UCLIBC_HAS_THREADS__ __pthread_mutex_lock(&(dir->dd_lock)); -#endif do { if (dir->dd_size <= dir->dd_nextloc) { @@ -59,9 +57,7 @@ struct dirent64 *readdir64(DIR * dir) } while (de->d_ino == 0); all_done: -#ifdef __UCLIBC_HAS_THREADS__ __pthread_mutex_unlock(&(dir->dd_lock)); -#endif return de; } diff --git a/libc/misc/dirent/readdir64_r.c b/libc/misc/dirent/readdir64_r.c index 1daae5116..7daf890dd 100644 --- a/libc/misc/dirent/readdir64_r.c +++ b/libc/misc/dirent/readdir64_r.c @@ -32,9 +32,7 @@ int readdir64_r(DIR *dir, struct dirent64 *entry, struct dirent64 **result) } de = NULL; -#ifdef __UCLIBC_HAS_THREADS__ __pthread_mutex_lock(&(dir->dd_lock)); -#endif do { if (dir->dd_size <= dir->dd_nextloc) { @@ -68,9 +66,7 @@ int readdir64_r(DIR *dir, struct dirent64 *entry, struct dirent64 **result) all_done: -#ifdef __UCLIBC_HAS_THREADS__ __pthread_mutex_unlock(&(dir->dd_lock)); -#endif return((de != NULL)? 0 : ret); } #endif /* __UCLIBC_HAS_LFS__ */ diff --git a/libc/misc/dirent/readdir_r.c b/libc/misc/dirent/readdir_r.c index 1c8eeadce..25cb80b63 100644 --- a/libc/misc/dirent/readdir_r.c +++ b/libc/misc/dirent/readdir_r.c @@ -5,7 +5,6 @@ #include <dirent.h> #include "dirstream.h" - int readdir_r(DIR *dir, struct dirent *entry, struct dirent **result) { int ret; @@ -18,9 +17,7 @@ int readdir_r(DIR *dir, struct dirent *entry, struct dirent **result) } de = NULL; -#ifdef __UCLIBC_HAS_THREADS__ __pthread_mutex_lock(&(dir->dd_lock)); -#endif do { if (dir->dd_size <= dir->dd_nextloc) { @@ -54,8 +51,7 @@ int readdir_r(DIR *dir, struct dirent *entry, struct dirent **result) all_done: -#ifdef __UCLIBC_HAS_THREADS__ __pthread_mutex_unlock(&(dir->dd_lock)); -#endif - return((de != NULL)? 0 : ret); + + return((de != NULL)? 0 : ret); } diff --git a/libc/misc/dirent/rewinddir.c b/libc/misc/dirent/rewinddir.c index 60ef71da7..f41ecc389 100644 --- a/libc/misc/dirent/rewinddir.c +++ b/libc/misc/dirent/rewinddir.c @@ -11,12 +11,8 @@ void rewinddir(DIR * dir) __set_errno(EBADF); return; } -#ifdef __UCLIBC_HAS_THREADS__ __pthread_mutex_lock(&(dir->dd_lock)); -#endif lseek(dir->dd_fd, 0, SEEK_SET); dir->dd_nextoff = dir->dd_nextloc = dir->dd_size = 0; -#ifdef __UCLIBC_HAS_THREADS__ __pthread_mutex_unlock(&(dir->dd_lock)); -#endif } diff --git a/libc/misc/dirent/scandir.c b/libc/misc/dirent/scandir.c index 8b08e4884..e80df58dc 100644 --- a/libc/misc/dirent/scandir.c +++ b/libc/misc/dirent/scandir.c @@ -20,6 +20,8 @@ /* Modified for uClibc by Erik Andersen */ +#define qsort __qsort + #include <dirent.h> #include <stdio.h> #include <string.h> diff --git a/libc/misc/dirent/scandir64.c b/libc/misc/dirent/scandir64.c index 2916285eb..46b6d5cef 100644 --- a/libc/misc/dirent/scandir64.c +++ b/libc/misc/dirent/scandir64.c @@ -20,6 +20,8 @@ /* Modified for uClibc by Erik Andersen */ +#define qsort __qsort + #include <features.h> #ifdef __UCLIBC_HAS_LFS__ #if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS != 64 diff --git a/libc/misc/dirent/seekdir.c b/libc/misc/dirent/seekdir.c index 139f1e1e5..507131097 100644 --- a/libc/misc/dirent/seekdir.c +++ b/libc/misc/dirent/seekdir.c @@ -3,19 +3,14 @@ #include <unistd.h> #include "dirstream.h" - void seekdir(DIR * dir, long int offset) { if (!dir) { __set_errno(EBADF); return; } -#ifdef __UCLIBC_HAS_THREADS__ __pthread_mutex_lock(&(dir->dd_lock)); -#endif dir->dd_nextoff = lseek(dir->dd_fd, offset, SEEK_SET); dir->dd_size = dir->dd_nextloc = 0; -#ifdef __UCLIBC_HAS_THREADS__ __pthread_mutex_unlock(&(dir->dd_lock)); -#endif } diff --git a/libc/misc/file/lockf.c b/libc/misc/file/lockf.c index 0962031da..29c91482a 100644 --- a/libc/misc/file/lockf.c +++ b/libc/misc/file/lockf.c @@ -43,7 +43,7 @@ int lockf (int fd, int cmd, off_t len) fl.l_type = F_RDLCK; if (fcntl (fd, F_GETLK, &fl) < 0) return -1; - if (fl.l_type == F_UNLCK || fl.l_pid == getpid ()) + if (fl.l_type == F_UNLCK || fl.l_pid == __getpid ()) return 0; __set_errno(EACCES); return -1; diff --git a/libc/misc/file/lockf64.c b/libc/misc/file/lockf64.c index eb70e8ddd..63c2ddfbe 100644 --- a/libc/misc/file/lockf64.c +++ b/libc/misc/file/lockf64.c @@ -77,7 +77,7 @@ int lockf64 (int fd, int cmd, off64_t len64) fl.l_type = F_RDLCK; if (fcntl (fd, F_GETLK, &fl) < 0) return -1; - if (fl.l_type == F_UNLCK || fl.l_pid == getpid ()) + if (fl.l_type == F_UNLCK || fl.l_pid == __getpid ()) return 0; __set_errno(EACCES); return -1; diff --git a/libc/misc/ftw/ftw.c b/libc/misc/ftw/ftw.c index c36ae45b6..6bd36d749 100644 --- a/libc/misc/ftw/ftw.c +++ b/libc/misc/ftw/ftw.c @@ -22,7 +22,10 @@ #define strlen __strlen #define mempcpy __mempcpy +#define stpcpy __stpcpy #define tsearch __tsearch +#define tdestroy __tdestroy +#define fchdir __fchdir #define _GNU_SOURCE #include <features.h> diff --git a/libc/misc/glob/glob.c b/libc/misc/glob/glob.c index 22f1874ab..3fc20dbc2 100644 --- a/libc/misc/glob/glob.c +++ b/libc/misc/glob/glob.c @@ -17,6 +17,7 @@ Cambridge, MA 02139, USA. */ #define strrchr __strrchr #define strcoll __strcoll +#define qsort __qsort #include <features.h> #include <stdlib.h> diff --git a/libc/misc/internals/tempname.c b/libc/misc/internals/tempname.c index 360c76879..99a8ac0d8 100644 --- a/libc/misc/internals/tempname.c +++ b/libc/misc/internals/tempname.c @@ -146,7 +146,7 @@ static void brain_damaged_fillrand(unsigned char *buf, unsigned int len) uint32_t high, low, rh; static uint64_t value; gettimeofday(&tv, NULL); - value += ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ getpid(); + value += ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ __getpid(); low = value & UINT32_MAX; high = value >> 32; for (i = 0; i < len; ++i) { diff --git a/libc/misc/locale/locale.c b/libc/misc/locale/locale.c index 77d3f1e5d..b73ffa3dd 100644 --- a/libc/misc/locale/locale.c +++ b/libc/misc/locale/locale.c @@ -46,6 +46,7 @@ * locale support had (8-bit codesets only). */ +#define stpcpy __stpcpy #define strtok_r __strtok_r #define _GNU_SOURCE @@ -1241,7 +1242,7 @@ __locale_t __newlocale(int category_mask, const char *locale, __locale_t base) j = 0; do { p = envstr[j]; - } while ((++j < 4) && (!(p = getenv(p)) || !*p)); + } while ((++j < 4) && (!(p = __getenv(p)) || !*p)); /* The user set something... is it valid? */ diff --git a/libc/misc/mntent/mntent.c b/libc/misc/mntent/mntent.c index 1af5a6b67..35767280e 100644 --- a/libc/misc/mntent/mntent.c +++ b/libc/misc/mntent/mntent.c @@ -7,14 +7,11 @@ #include <mntent.h> #ifdef __UCLIBC_HAS_THREADS__ -#include <pthread.h> +# include <pthread.h> static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER; -# define LOCK __pthread_mutex_lock(&mylock) -# define UNLOCK __pthread_mutex_unlock(&mylock); -#else -# define LOCK -# define UNLOCK #endif +#define LOCK __pthread_mutex_lock(&mylock) +#define UNLOCK __pthread_mutex_unlock(&mylock) /* Reentrant version of getmntent. */ struct mntent *getmntent_r (FILE *filep, diff --git a/libc/misc/regex/regex.c b/libc/misc/regex/regex.c index d367211c5..bf8958a66 100644 --- a/libc/misc/regex/regex.c +++ b/libc/misc/regex/regex.c @@ -53,6 +53,10 @@ extern int __iswctype (wint_t __wc, wctype_t __desc) /*attribute_hidden*/; #define strcmp __strcmp #define strlen __strlen #define strncpy __strncpy +#define getenv __getenv + +extern void *__mempcpy (void *__restrict __dest, + __const void *__restrict __src, size_t __n) /*attribute_hidden*/; #endif /* Make sure noone compiles this code with a C++ compiler. */ diff --git a/libc/misc/search/hsearch.c b/libc/misc/search/hsearch.c index 067e4973b..a9400f3ca 100644 --- a/libc/misc/search/hsearch.c +++ b/libc/misc/search/hsearch.c @@ -17,6 +17,10 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#define hdestroy_r __hdestroy_r +#define hsearch_r __hsearch_r +#define hcreate_r __hcreate_r + #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif diff --git a/libc/misc/search/hsearch_r.c b/libc/misc/search/hsearch_r.c index 0f96180b1..d297b3280 100644 --- a/libc/misc/search/hsearch_r.c +++ b/libc/misc/search/hsearch_r.c @@ -67,7 +67,7 @@ static int isprime (unsigned int number) indexing as explained in the comment for the hsearch function. The contents of the table is zeroed, especially the field used becomes zero. */ -int hcreate_r (size_t nel, struct hsearch_data *htab) +int attribute_hidden __hcreate_r (size_t nel, struct hsearch_data *htab) { /* Test for correct arguments. */ if (htab == NULL) @@ -96,13 +96,13 @@ int hcreate_r (size_t nel, struct hsearch_data *htab) /* everything went alright */ return 1; } -/* libc_hidden_def (hcreate_r) */ +strong_alias(__hcreate_r,hcreate_r) #endif #ifdef L_hdestroy_r /* After using the hash table it has to be destroyed. The used memory can be freed and the local static variable can be marked as not used. */ -void hdestroy_r (struct hsearch_data *htab) +void attribute_hidden __hdestroy_r (struct hsearch_data *htab) { /* Test for correct arguments. */ if (htab == NULL) @@ -118,7 +118,7 @@ void hdestroy_r (struct hsearch_data *htab) /* the sign for an existing table is an value != NULL in htable */ htab->table = NULL; } -/* libc_hidden_def (hdestroy_r) */ +strong_alias(__hdestroy_r,hdestroy_r) #endif #ifdef L_hsearch_r @@ -135,7 +135,7 @@ void hdestroy_r (struct hsearch_data *htab) means used. The used field can be used as a first fast comparison for equality of the stored and the parameter value. This helps to prevent unnecessary expensive calls of strcmp. */ -int hsearch_r (ENTRY item, ACTION action, ENTRY **retval, +int attribute_hidden __hsearch_r (ENTRY item, ACTION action, ENTRY **retval, struct hsearch_data *htab) { unsigned int hval; @@ -224,5 +224,5 @@ int hsearch_r (ENTRY item, ACTION action, ENTRY **retval, *retval = NULL; return 0; } -/* libc_hidden_def (hsearch_r) */ +strong_alias(__hsearch_r,hsearch_r) #endif diff --git a/libc/misc/search/tsearch.c b/libc/misc/search/tsearch.c index 1da6b571e..93a2c678f 100644 --- a/libc/misc/search/tsearch.c +++ b/libc/misc/search/tsearch.c @@ -205,13 +205,14 @@ tdestroy_recurse (node *root, __free_fn_t freefct) free (root); } -void tdestroy (void *vroot, __free_fn_t freefct) +void attribute_hidden __tdestroy (void *vroot, __free_fn_t freefct) { node *root = (node *) vroot; if (root != NULL) { tdestroy_recurse (root, freefct); } } +strong_alias(__tdestroy,tdestroy) #endif /* tsearch.c ends here */ diff --git a/libc/misc/syslog/syslog.c b/libc/misc/syslog/syslog.c index 69ff0b38b..5605aecf1 100644 --- a/libc/misc/syslog/syslog.c +++ b/libc/misc/syslog/syslog.c @@ -31,6 +31,10 @@ * SUCH DAMAGE. */ +#define time __time +#define ctime __ctime +#define sigaction __sigaction_internal + #define __FORCE_GLIBC #define _GNU_SOURCE #include <features.h> @@ -82,14 +86,11 @@ #ifdef __UCLIBC_HAS_THREADS__ -#include <pthread.h> +# include <pthread.h> static pthread_mutex_t mylock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; -# define LOCK __pthread_mutex_lock(&mylock) -# define UNLOCK __pthread_mutex_unlock(&mylock); -#else -# define LOCK -# define UNLOCK #endif +#define LOCK __pthread_mutex_lock(&mylock) +#define UNLOCK __pthread_mutex_unlock(&mylock) static int LogFile = -1; /* fd for log */ @@ -136,18 +137,8 @@ sigpipe_handler (int sig) * syslog, vsyslog -- * print message on log file; output is intended for syslogd(8). */ -void -syslog(int pri, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - vsyslog(pri, fmt, ap); - va_end(ap); -} - -void -vsyslog( int pri, const char *fmt, va_list ap ) +void attribute_hidden +__vsyslog( int pri, const char *fmt, va_list ap ) { register char *p; char *last_chr, *head_end, *end, *stdp; @@ -190,7 +181,7 @@ vsyslog( int pri, const char *fmt, va_list ap ) p += sprintf(p, "<BUFFER OVERRUN ATTEMPT>"); } if (LogStat & LOG_PID) - p += sprintf(p, "[%d]", getpid()); + p += sprintf(p, "[%d]", __getpid()); if (LogTag) { *p++ = ':'; *p++ = ' '; @@ -267,12 +258,24 @@ getout: sigaction (SIGPIPE, &oldaction, (struct sigaction *) NULL); } +strong_alias(__vsyslog,vsyslog) + +void attribute_hidden +__syslog(int pri, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + __vsyslog(pri, fmt, ap); + va_end(ap); +} +strong_alias(__syslog,syslog) /* * OPENLOG -- open system log */ -void -openlog( const char *ident, int logstat, int logfac ) +void attribute_hidden +__openlog( const char *ident, int logstat, int logfac ) { int logType = SOCK_DGRAM; @@ -319,15 +322,17 @@ retry: UNLOCK; } +strong_alias(__openlog,openlog) /* * CLOSELOG -- close the system log */ -void -closelog( void ) +void attribute_hidden +__closelog( void ) { closelog_intern(1); } +strong_alias(__closelog,closelog) /* setlogmask -- set the log mask level */ int setlogmask(int pmask) diff --git a/libc/misc/sysvipc/shm.c b/libc/misc/sysvipc/shm.c index 9c6f019bf..20e28d3b1 100644 --- a/libc/misc/sysvipc/shm.c +++ b/libc/misc/sysvipc/shm.c @@ -17,8 +17,8 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* SHMLBA is using it */ -#define __getpagesize __libc_getpagesize +/* SHMLBA uses it */ +#define __getpagesize __getpagesize_internal #include <stdlib.h> #include <errno.h> diff --git a/libc/misc/time/adjtime.c b/libc/misc/time/adjtime.c index 2049bc896..fd33ff60d 100644 --- a/libc/misc/time/adjtime.c +++ b/libc/misc/time/adjtime.c @@ -1,3 +1,5 @@ +#define adjtimex __adjtimex + #include <limits.h> #include <sys/time.h> #include <sys/timex.h> @@ -49,4 +51,3 @@ adjtime(const struct timeval * itv, struct timeval * otv) } return 0; } - diff --git a/libc/misc/time/time.c b/libc/misc/time/time.c index 4d3c43492..65b925cf6 100644 --- a/libc/misc/time/time.c +++ b/libc/misc/time/time.c @@ -129,7 +129,6 @@ * differs (intentionally) from glibc's behavior. */ -#define _uintmaxtostr __libc__uintmaxtostr #define strnlen __strnlen #define _GNU_SOURCE @@ -184,6 +183,11 @@ extern struct tm __time_tm; +extern struct tm *__localtime_r (__const time_t *__restrict __timer, + struct tm *__restrict __tp) attribute_hidden; + +extern struct tm *__localtime (__const time_t *__timer) attribute_hidden; + typedef struct { long gmt_offset; long dst_offset; @@ -195,21 +199,12 @@ typedef struct { } rule_struct; #ifdef __UCLIBC_HAS_THREADS__ - -#include <pthread.h> - +# include <pthread.h> extern pthread_mutex_t _time_tzlock; - +#endif #define TZLOCK __pthread_mutex_lock(&_time_tzlock) #define TZUNLOCK __pthread_mutex_unlock(&_time_tzlock) -#else - -#define TZLOCK ((void) 0) -#define TZUNLOCK ((void) 0) - -#endif - extern rule_struct _time_tzinfo[2]; extern struct tm *_time_t2tm(const time_t *__restrict timer, @@ -386,6 +381,8 @@ strong_alias(__asctime_r,asctime_r) /**********************************************************************/ #ifdef L_clock +#define times __times + #include <sys/times.h> #ifndef __BCC__ @@ -452,12 +449,12 @@ clock_t clock(void) /**********************************************************************/ #ifdef L_ctime -char *ctime(const time_t *clock) +char attribute_hidden *__ctime(const time_t *clock) { /* ANSI/ISO/SUSv3 say that ctime is equivalent to the following. */ - return __asctime(localtime(clock)); + return __asctime(__localtime(clock)); } - +strong_alias(__ctime,ctime) #endif /**********************************************************************/ #ifdef L_ctime_r @@ -466,7 +463,7 @@ char *ctime_r(const time_t *clock, char *buf) { struct tm xtm; - return __asctime_r(localtime_r(clock, &xtm), buf); + return __asctime_r(__localtime_r(clock, &xtm), buf); } #endif @@ -534,22 +531,23 @@ struct tm *gmtime_r(const time_t *__restrict timer, /**********************************************************************/ #ifdef L_localtime -struct tm *localtime(const time_t *timer) +struct tm attribute_hidden *__localtime(const time_t *timer) { register struct tm *ptm = &__time_tm; /* In this implementation, tzset() is called by localtime_r(). */ - localtime_r(timer, ptm); /* Can return NULL... */ + __localtime_r(timer, ptm); /* Can return NULL... */ return ptm; } +strong_alias(__localtime,localtime) #endif /**********************************************************************/ #ifdef L_localtime_r -struct tm *localtime_r(register const time_t *__restrict timer, +struct tm attribute_hidden *__localtime_r(register const time_t *__restrict timer, register struct tm *__restrict result) { TZLOCK; @@ -562,6 +560,7 @@ struct tm *localtime_r(register const time_t *__restrict timer, return result; } +strong_alias(__localtime_r,localtime_r) #endif /**********************************************************************/ @@ -1542,7 +1541,7 @@ char *__XL(strptime)(const char *__restrict buf, const char *__restrict format, buf = o; if (!code) { /* s */ - localtime_r(&t, tm); /* TODO: check for failure? */ + __localtime_r(&t, tm); /* TODO: check for failure? */ i = 0; do { /* Now copy values from tm to fields. */ fields[i] = ((int *) tm)[i]; @@ -1806,7 +1805,7 @@ void tzset(void) TZLOCK; - e = getenv(TZ); /* TZ env var always takes precedence. */ + e = __getenv(TZ); /* TZ env var always takes precedence. */ #if defined(__UCLIBC_HAS_TZ_FILE__) && !defined(__UCLIBC_HAS_TZ_FILE_READ_MANY__) /* Put this inside the lock to prevent the possiblity of two different diff --git a/libc/misc/ttyent/getttyent.c b/libc/misc/ttyent/getttyent.c index c15228a24..04f511921 100644 --- a/libc/misc/ttyent/getttyent.c +++ b/libc/misc/ttyent/getttyent.c @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ -#define __fsetlocking __libc_fsetlocking +#define __fsetlocking __fsetlocking_internal #define _GNU_SOURCE #include <features.h> @@ -46,19 +46,6 @@ static FILE *tf; static struct ttyent tty; -struct ttyent * getttynam(const char *tty) -{ - register struct ttyent *t; - - setttyent(); - while ((t = getttyent())) - if (!__strcmp(tty, t->ty_name)) - break; - endttyent(); - return (t); -} - - /* Skip over the current field, removing quotes, and return * a pointer to the next field. */ @@ -101,13 +88,30 @@ static char * value(register char *p) return ((p = __strchr(p, '=')) ? ++p : NULL); } -struct ttyent * getttyent(void) +int attribute_hidden __setttyent(void) +{ + + if (tf) { + rewind(tf); + return (1); + } else if ((tf = fopen(_PATH_TTYS, "r"))) { + /* We do the locking ourselves. */ +#ifdef __UCLIBC_HAS_THREADS__ + __fsetlocking (tf, FSETLOCKING_BYCALLER); +#endif + return (1); + } + return (0); +} +strong_alias(__setttyent,setttyent) + +struct ttyent attribute_hidden * __getttyent(void) { register int c; register char *p; static char *line = NULL; - if (!tf && !setttyent()) + if (!tf && !__setttyent()) return (NULL); if (!line) { @@ -177,24 +181,9 @@ struct ttyent * getttyent(void) *p = '\0'; return (&tty); } +strong_alias(__getttyent,getttyent) -int setttyent(void) -{ - - if (tf) { - rewind(tf); - return (1); - } else if ((tf = fopen(_PATH_TTYS, "r"))) { - /* We do the locking ourselves. */ -#ifdef __UCLIBC_HAS_THREADS__ - __fsetlocking (tf, FSETLOCKING_BYCALLER); -#endif - return (1); - } - return (0); -} - -int endttyent(void) +int attribute_hidden __endttyent(void) { int rval; @@ -205,3 +194,16 @@ int endttyent(void) } return (1); } +strong_alias(__endttyent,endttyent) + +struct ttyent * getttynam(const char *tty) +{ + register struct ttyent *t; + + __setttyent(); + while ((t = __getttyent())) + if (!__strcmp(tty, t->ty_name)) + break; + __endttyent(); + return (t); +} diff --git a/libc/misc/utmp/utent.c b/libc/misc/utmp/utent.c index c3d9ab620..e03d4528f 100644 --- a/libc/misc/utmp/utent.c +++ b/libc/misc/utmp/utent.c @@ -23,14 +23,11 @@ #ifdef __UCLIBC_HAS_THREADS__ -#include <pthread.h> +# include <pthread.h> static pthread_mutex_t utmplock = PTHREAD_MUTEX_INITIALIZER; -# define LOCK __pthread_mutex_lock(&utmplock) -# define UNLOCK __pthread_mutex_unlock(&utmplock) -#else -# define LOCK -# define UNLOCK #endif +#define LOCK __pthread_mutex_lock(&utmplock) +#define UNLOCK __pthread_mutex_unlock(&utmplock) diff --git a/libc/misc/utmp/wtent.c b/libc/misc/utmp/wtent.c index bb5244878..0900ef379 100644 --- a/libc/misc/utmp/wtent.c +++ b/libc/misc/utmp/wtent.c @@ -34,7 +34,7 @@ void logwtmp (const char *line, const char *name, const char *host) __memset (&(lutmp), 0, sizeof (struct utmp)); lutmp.ut_type = (name && *name)? USER_PROCESS : DEAD_PROCESS; - lutmp.ut_pid = getpid(); + lutmp.ut_pid = __getpid(); __strncpy(lutmp.ut_line, line, sizeof(lutmp.ut_line)-1); __strncpy(lutmp.ut_name, name, sizeof(lutmp.ut_name)-1); __strncpy(lutmp.ut_host, host, sizeof(lutmp.ut_host)-1); diff --git a/libc/misc/wordexp/wordexp.c b/libc/misc/wordexp/wordexp.c index 5e9133c83..9cdeaf162 100644 --- a/libc/misc/wordexp/wordexp.c +++ b/libc/misc/wordexp/wordexp.c @@ -20,9 +20,14 @@ Boston, MA 02111-1307, USA. */ #define mempcpy __mempcpy +#define stpcpy __stpcpy #define strndup __strndup #define strspn __strspn #define unsetenv __unsetenv +#define waitpid __waitpid +#define kill __kill +#define getuid __getuid +#define execve __execve #define _GNU_SOURCE #include <sys/cdefs.h> @@ -283,7 +288,7 @@ parse_tilde(char **word, size_t * word_length, size_t * max_length, results are unspecified. We do a lookup on the uid if HOME is unset. */ - home = getenv("HOME"); + home = __getenv("HOME"); if (home != NULL) { *word = w_addstr(*word, word_length, max_length, home); if (*word == NULL) @@ -1328,7 +1333,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length, /* Is it `$$'? */ if (*env == '$') { buffer[20] = '\0'; - value = _itoa(getpid(), &buffer[20]); + value = _itoa(__getpid(), &buffer[20]); } /* Is it `${#*}' or `${#@}'? */ else if ((*env == '*' || *env == '@') && seen_hash) { @@ -1395,7 +1400,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length, } } } else - value = getenv(env); + value = __getenv(env); if (value == NULL && (flags & WRDE_UNDEF)) { /* Variable not defined. */ @@ -2067,7 +2072,7 @@ int wordexp(const char *words, wordexp_t * we, int flags) /* Find out what the field separators are. * There are two types: whitespace and non-whitespace. */ - ifs = getenv("IFS"); + ifs = __getenv("IFS"); if (!ifs) /* IFS unset - use <space><tab><newline>. */ |