summaryrefslogtreecommitdiff
path: root/libc/misc/internals
diff options
context:
space:
mode:
Diffstat (limited to 'libc/misc/internals')
-rw-r--r--libc/misc/internals/__uClibc_main.c45
-rw-r--r--libc/misc/internals/tempname.c43
2 files changed, 53 insertions, 35 deletions
diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c
index 414342c79..9987324b2 100644
--- a/libc/misc/internals/__uClibc_main.c
+++ b/libc/misc/internals/__uClibc_main.c
@@ -13,11 +13,6 @@
* avoided in the static library case.
*/
-#define getgid __getgid
-#define getuid __getuid
-#define getegid __getegid
-#define geteuid __geteuid
-
#define _ERRNO_H
#include <features.h>
#include <unistd.h>
@@ -33,6 +28,21 @@
#include <sys/stat.h>
#include <sys/sysmacros.h>
+libc_hidden_proto(memcpy)
+libc_hidden_proto(strrchr)
+libc_hidden_proto(getgid)
+libc_hidden_proto(getuid)
+libc_hidden_proto(getegid)
+libc_hidden_proto(geteuid)
+libc_hidden_proto(fstat)
+libc_hidden_proto(abort)
+libc_hidden_proto(exit)
+
+extern int __libc_open (__const char *__file, int __oflag, ...) __nonnull ((1));
+libc_hidden_proto(__libc_open)
+extern int __libc_fcntl (int __fd, int __cmd, ...);
+libc_hidden_proto(__libc_fcntl)
+
#ifndef SHARED
void *__libc_stack_end=NULL;
@@ -84,7 +94,8 @@ weak_alias(__environ, environ)
/* TODO: don't export __pagesize; we cant now because libpthread uses it */
size_t __pagesize = 0;
-hidden_strong_alias(__pagesize,__pagesize_internal)
+libc_hidden_proto(__pagesize)
+libc_hidden_def(__pagesize)
#ifndef O_NOFOLLOW
# define O_NOFOLLOW 0
@@ -95,18 +106,17 @@ hidden_strong_alias(__pagesize,__pagesize_internal)
static void __check_one_fd(int fd, int mode)
{
/* Check if the specified fd is already open */
- if (unlikely(__fcntl(fd, F_GETFD)==-1 && *(__errno_location())==EBADF))
+ if (unlikely(__libc_fcntl(fd, F_GETFD)==-1 && *(__errno_location())==EBADF))
{
/* The descriptor is probably not open, so try to use /dev/null */
struct stat st;
- int nullfd = __open(_PATH_DEVNULL, mode);
+ int nullfd = __libc_open(_PATH_DEVNULL, mode);
/* /dev/null is major=1 minor=3. Make absolutely certain
* that is in fact the device that we have opened and not
* some other wierd file... */
- if ( (nullfd!=fd) || __fstat(fd, &st) || !S_ISCHR(st.st_mode) ||
+ if ( (nullfd!=fd) || fstat(fd, &st) || !S_ISCHR(st.st_mode) ||
(st.st_rdev != makedev(1, 3)))
{
- /* Somebody is trying some trickery here... */
abort();
}
}
@@ -152,7 +162,7 @@ void __uClibc_init(void)
/* Setup an initial value. This may not be perfect, but is
* better than malloc using __pagesize=0 for atexit, ctors, etc. */
- __pagesize_internal = PAGE_SIZE;
+ __pagesize = PAGE_SIZE;
#ifdef __UCLIBC_HAS_THREADS__
/* Before we start initializing uClibc we have to call
@@ -189,7 +199,8 @@ void __uClibc_init(void)
_stdio_init();
}
-hidden_strong_alias(__uClibc_init,__uClibc_init_internal)
+libc_hidden_proto(__uClibc_init)
+libc_hidden_def(__uClibc_init)
#ifdef __UCLIBC_CTOR_DTOR__
void attribute_hidden (*__app_fini)(void) = NULL;
@@ -237,7 +248,7 @@ __uClibc_main(int (*main)(int, char **, char **), int argc,
while (*aux_dat) {
ElfW(auxv_t) *auxv_entry = (ElfW(auxv_t) *) aux_dat;
if (auxv_entry->a_type <= AT_EGID) {
- __memcpy(&(auxvt[auxv_entry->a_type]), auxv_entry, sizeof(ElfW(auxv_t)));
+ memcpy(&(auxvt[auxv_entry->a_type]), auxv_entry, sizeof(ElfW(auxv_t)));
}
aux_dat += 2;
}
@@ -246,11 +257,11 @@ __uClibc_main(int (*main)(int, char **, char **), int argc,
/* We need to initialize uClibc. If we are dynamically linked this
* may have already been completed by the shared lib loader. We call
* __uClibc_init() regardless, to be sure the right thing happens. */
- __uClibc_init_internal();
+ __uClibc_init();
#ifdef __ARCH_HAS_MMU__
/* Make certain getpagesize() gives the correct answer */
- __pagesize_internal = (auxvt[AT_PAGESZ].a_un.a_val)? auxvt[AT_PAGESZ].a_un.a_val : PAGE_SIZE;
+ __pagesize = (auxvt[AT_PAGESZ].a_un.a_val)? auxvt[AT_PAGESZ].a_un.a_val : PAGE_SIZE;
/* Prevent starting SUID binaries where the stdin. stdout, and
* stderr file descriptors are not already opened. */
@@ -267,7 +278,7 @@ __uClibc_main(int (*main)(int, char **, char **), int argc,
#ifdef __UCLIBC_HAS_PROGRAM_INVOCATION_NAME__
__progname_full = *argv;
- __progname = __strrchr(*argv, '/');
+ __progname = strrchr(*argv, '/');
if (__progname != NULL)
++__progname;
else
@@ -300,5 +311,5 @@ __uClibc_main(int (*main)(int, char **, char **), int argc,
/*
* Finally, invoke application's main and then exit.
*/
- __exit(main(argc, argv, __environ));
+ exit(main(argc, argv, __environ));
}
diff --git a/libc/misc/internals/tempname.c b/libc/misc/internals/tempname.c
index 64fa1e14b..b8b421f13 100644
--- a/libc/misc/internals/tempname.c
+++ b/libc/misc/internals/tempname.c
@@ -31,10 +31,6 @@
* Use brain damaged getpid() if real random fails.
*/
-#define open64 __open64
-#define mkdir __mkdir
-#define gettimeofday __gettimeofday
-
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
@@ -49,12 +45,23 @@
#include <sys/time.h>
#include "tempname.h"
+libc_hidden_proto(strlen)
+libc_hidden_proto(strcmp)
+libc_hidden_proto(sprintf)
+libc_hidden_proto(mkdir)
+libc_hidden_proto(open)
+libc_hidden_proto(open64)
+libc_hidden_proto(read)
+libc_hidden_proto(close)
+libc_hidden_proto(getpid)
+libc_hidden_proto(stat)
+libc_hidden_proto(gettimeofday)
/* Return nonzero if DIR is an existent directory. */
static int direxists (const char *dir)
{
struct stat buf;
- return __stat(dir, &buf) == 0 && S_ISDIR (buf.st_mode);
+ return stat(dir, &buf) == 0 && S_ISDIR (buf.st_mode);
}
/* Path search algorithm, for tmpnam, tmpfile, etc. If DIR is
@@ -76,7 +83,7 @@ int attribute_hidden ___path_search (char *tmpl, size_t tmpl_len, const char *di
}
else
{
- plen = __strlen (pfx);
+ plen = strlen (pfx);
if (plen > 5)
plen = 5;
}
@@ -98,7 +105,7 @@ int attribute_hidden ___path_search (char *tmpl, size_t tmpl_len, const char *di
{
if (direxists (P_tmpdir))
dir = P_tmpdir;
- else if (__strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp"))
+ else if (strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp"))
dir = "/tmp";
else
{
@@ -107,7 +114,7 @@ int attribute_hidden ___path_search (char *tmpl, size_t tmpl_len, const char *di
}
}
- dlen = __strlen (dir);
+ dlen = strlen (dir);
while (dlen > 1 && dir[dlen - 1] == '/')
dlen--; /* remove trailing slashes */
@@ -118,7 +125,7 @@ int attribute_hidden ___path_search (char *tmpl, size_t tmpl_len, const char *di
return -1;
}
- __sprintf (tmpl, "%.*s/%.*sXXXXXX", dlen, dir, plen, pfx);
+ sprintf (tmpl, "%.*s/%.*sXXXXXX", dlen, dir, plen, pfx);
return 0;
}
@@ -131,13 +138,13 @@ static unsigned int fillrand(unsigned char *buf, unsigned int len)
{
int fd;
unsigned int result = -1;
- fd = __open("/dev/urandom", O_RDONLY);
+ fd = open("/dev/urandom", O_RDONLY);
if (fd < 0) {
- fd = __open("/dev/random", O_RDONLY | O_NONBLOCK);
+ fd = open("/dev/random", O_RDONLY | O_NONBLOCK);
}
if (fd >= 0) {
- result = __read(fd, buf, len);
- __close(fd);
+ result = read(fd, buf, len);
+ close(fd);
}
return result;
}
@@ -149,7 +156,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) {
@@ -188,10 +195,10 @@ int attribute_hidden __gen_tempname (char *tmpl, int kind)
unsigned char randomness[6];
size_t len;
- len = __strlen (tmpl);
+ len = strlen (tmpl);
/* This is where the Xs start. */
XXXXXX = tmpl + len - 6;
- if (len < 6 || __strcmp (XXXXXX, "XXXXXX"))
+ if (len < 6 || strcmp (XXXXXX, "XXXXXX"))
{
__set_errno (EINVAL);
return -1;
@@ -212,7 +219,7 @@ int attribute_hidden __gen_tempname (char *tmpl, int kind)
case __GT_NOCREATE:
{
struct stat st;
- if (__stat (tmpl, &st) < 0) {
+ if (stat (tmpl, &st) < 0) {
if (errno == ENOENT) {
fd = 0;
goto restore_and_ret;
@@ -223,7 +230,7 @@ int attribute_hidden __gen_tempname (char *tmpl, int kind)
fd = 0;
}
case __GT_FILE:
- fd = __open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
+ fd = open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
break;
#if defined __UCLIBC_HAS_LFS__
case __GT_BIGFILE: