* bsdlib.cc (logwtmp): Move from syscalls.cc to here.
(login): Ditto.
(logout): Ditto.
* winsup.h (EXPORT_ALIAS): New macro.
* exec.cc: Define alias symbols using EXPORT_ALIAS macro.
* syscalls.cc: Ditto.
* times.cc: Ditto.
+2004-09-10 Corinna Vinschen <corinna@vinschen.de>
+
+ * Makefile.in: Create libutil.a from bsdlib.o exports.
+ * bsdlib.cc (logwtmp): Move from syscalls.cc to here.
+ (login): Ditto.
+ (logout): Ditto.
+
+ * winsup.h (EXPORT_ALIAS): New macro.
+ * exec.cc: Define alias symbols using EXPORT_ALIAS macro.
+ * syscalls.cc: Ditto.
+ * times.cc: Ditto.
+
2004-09-09 Corinna Vinschen <corinna@vinschen.de>
* fhandler_tape.cc (fhandler_dev_tape::open): Fix typo.
PWD:=${shell pwd}
LIB_NAME:=$(PWD)/libcygwin.a
LIBSERVER:=@LIBSERVER@
-SUBLIBS:=$(PWD)/libpthread.a $(PWD)/libm.a $(PWD)/libc.a
+SUBLIBS:=$(PWD)/libpthread.a $(PWD)/libutil.a $(PWD)/libm.a $(PWD)/libc.a
EXTRALIBS:=libautomode.a libbinmode.a libtextmode.a libtextreadmode.a
INSTOBJS:=automode.o binmode.o textmode.o textreadmode.o
TARGET_LIBS:=$(LIB_NAME) $(CYGWIN_START) $(GMON_START) $(LIBGMON_A) $(SUBLIBS) $(INSTOBJS) $(EXTRALIBS)
$(PWD)/libpthread.a: speclib $(LIB_NAME) pthread.o thread.o
/bin/sh ${word 1, $^} $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
+$(PWD)/libutil.a: speclib $(LIB_NAME) bsdlib.o
+ /bin/sh ${word 1, $^} $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
+
$(PWD)/libm.a: speclib $(LIB_NAME) $(LIBM)
/bin/sh ${word 1, $^} $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
-$(PWD)/libc.a: speclib $(LIB_NAME) $(PWD)/libm.a libpthread.a
+$(PWD)/libc.a: speclib $(LIB_NAME) $(PWD)/libm.a libpthread.a libutil.a
/bin/sh ${word 1, $^} -v $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
lib%.a: %.o
return spawnve (_P_OVERLAY, path, argv, envp);
}
-extern "C" int _execve (const char *, char *const [], char *const [])
- __attribute__ ((alias ("execve")));
+EXPORT_ALIAS (execve, _execve)
extern "C" int
execl (const char *path, const char *arg0, ...)
__progname = (char *)newprogname;
}
}
+
+extern "C" void
+logwtmp (const char *line, const char *user, const char *host)
+{
+ struct utmp ut;
+ memset (&ut, 0, sizeof ut);
+ ut.ut_type = USER_PROCESS;
+ ut.ut_pid = getpid ();
+ if (line)
+ strncpy (ut.ut_line, line, sizeof ut.ut_line);
+ time (&ut.ut_time);
+ if (user)
+ strncpy (ut.ut_user, user, sizeof ut.ut_user);
+ if (host)
+ strncpy (ut.ut_host, host, sizeof ut.ut_host);
+ updwtmp (_PATH_WTMP, &ut);
+}
+
+extern "C" void
+login (struct utmp *ut)
+{
+ pututline (ut);
+ endutent ();
+ updwtmp (_PATH_WTMP, ut);
+}
+
+extern "C" int
+logout (char *line)
+{
+ struct utmp ut_buf, *ut;
+
+ memset (&ut_buf, 0, sizeof ut_buf);
+ strncpy (ut_buf.ut_line, line, sizeof ut_buf.ut_line);
+ setutent ();
+ ut = getutline (&ut_buf);
+
+ if (ut)
+ {
+ ut->ut_type = DEAD_PROCESS;
+ memset (ut->ut_user, 0, sizeof ut->ut_user);
+ memset (ut->ut_host, 0, sizeof ut->ut_host);
+ time (&ut->ut_time);
+ debug_printf ("set logout time for %s", line);
+ pututline (ut);
+ endutent ();
+ return 1;
+ }
+ return 0;
+}
return readv (fd, &iov, 1);
}
-extern "C" ssize_t _read (int, void *, size_t)
- __attribute__ ((alias ("read")));
+EXPORT_ALIAS (read, _read)
extern "C" ssize_t
write (int fd, const void *ptr, size_t len)
return writev (fd, &iov, 1);
}
-extern "C" ssize_t _write (int fd, const void *ptr, size_t len)
- __attribute__ ((alias ("write")));
+EXPORT_ALIAS (write, _write)
extern "C" ssize_t
readv (int fd, const struct iovec *const iov, const int iovcnt)
return res;
}
-extern "C" int _open (const char *, int flags, ...)
- __attribute__ ((alias ("open")));
-
-extern "C" int _open64 (const char *, int flags, ...)
- __attribute__ ((alias ("open")));
+EXPORT_ALIAS (open, _open )
+EXPORT_ALIAS (open, _open64 )
extern "C" _off64_t
lseek64 (int fd, _off64_t pos, int dir)
return res;
}
-extern "C" int _lseek64 (int fd, _off64_t pos, int dir)
- __attribute__ ((alias ("lseek64")));
+EXPORT_ALIAS (lseek64, _lseek64)
extern "C" _off_t
lseek (int fd, _off_t pos, int dir)
return lseek64 (fd, (_off64_t) pos, dir);
}
-extern "C" _off_t _lseek (int, _off_t, int)
- __attribute__ ((alias ("lseek")));
+EXPORT_ALIAS (lseek, _lseek)
extern "C" int
close (int fd)
return res;
}
-extern "C" int _close (int) __attribute__ ((alias ("close")));
+EXPORT_ALIAS (close, _close)
extern "C" int
isatty (int fd)
}
}
-extern "C" void
-logwtmp (const char *line, const char *user, const char *host)
-{
- struct utmp ut;
- memset (&ut, 0, sizeof ut);
- ut.ut_type = USER_PROCESS;
- ut.ut_pid = getpid ();
- if (line)
- strncpy (ut.ut_line, line, sizeof ut.ut_line);
- time (&ut.ut_time);
- if (user)
- strncpy (ut.ut_user, user, sizeof ut.ut_user);
- if (host)
- strncpy (ut.ut_host, host, sizeof ut.ut_host);
- updwtmp (_PATH_WTMP, &ut);
-}
-
-extern "C" void
-login (struct utmp *ut)
-{
- pututline (ut);
- endutent ();
- updwtmp (_PATH_WTMP, ut);
-}
-
-extern "C" int
-logout (char *line)
-{
- struct utmp ut_buf, *ut;
-
- memset (&ut_buf, 0, sizeof ut_buf);
- strncpy (ut_buf.ut_line, line, sizeof ut_buf.ut_line);
- setutent ();
- ut = getutline (&ut_buf);
-
- if (ut)
- {
- ut->ut_type = DEAD_PROCESS;
- memset (ut->ut_user, 0, sizeof ut->ut_user);
- memset (ut->ut_host, 0, sizeof ut->ut_host);
- time (&ut->ut_time);
- debug_printf ("set logout time for %s", line);
- pututline (ut);
- endutent ();
- return 1;
- }
- return 0;
-}
-
static int utmp_fd = -1;
static bool utmp_readonly = false;
static char *utmp_file = (char *) _PATH_UTMP;
return tc;
}
-extern "C" clock_t _times (struct tms *) __attribute__((alias ("times")));
+EXPORT_ALIAS (times, _times)
/* settimeofday: BSD */
extern "C" int
return 0;
}
-extern "C" int _gettimeofday (struct timeval *, struct timezone *)
- __attribute__((alias ("gettimeofday")));
+EXPORT_ALIAS (gettimeofday, _gettimeofday)
/* Cygwin internal */
void
#define NO_COPY __attribute__((nocommon)) __attribute__((section(".data_cygwin_nocopy")))
#define NO_COPY_INIT __attribute__((section(".data_cygwin_nocopy")))
+#define EXPORT_ALIAS(sym,symalias) extern "C" __typeof (sym) symalias __attribute__ ((alias(#sym)));
+
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ >= 199900L
#define NEW_MACRO_VARARGS
#endif