fix Linux compile issues
- include stubs for Solaris specific functionality - include some missing standard headers - guard Solaris specific constructs with preprocessor conditionals - fix pointer-to-int-cast undefined behavior
This commit is contained in:
parent
c0dfa85aa1
commit
43a5295e69
|
@ -46,6 +46,7 @@
|
|||
#include <libintl.h>
|
||||
#include <mk/defs.h>
|
||||
#include <mksh/misc.h> /* retmem_mb() */
|
||||
#include <ctype.h>
|
||||
|
||||
struct ranlib {
|
||||
union {
|
||||
|
|
|
@ -43,13 +43,18 @@
|
|||
#include <poll.h>
|
||||
#include <libintl.h>
|
||||
#include <signal.h>
|
||||
#if defined(sun) || defined(__sun)
|
||||
// XXX really needed, even on Solaris?
|
||||
#include <stropts.h>
|
||||
#else
|
||||
#endif
|
||||
#include <sys/errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/utsname.h> /* uname() */
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h> /* close() */
|
||||
#include <comp/namelen.h>
|
||||
|
||||
/*
|
||||
* Defined macros
|
||||
|
|
27
bin/main.cc
27
bin/main.cc
|
@ -48,14 +48,23 @@
|
|||
#include <sys/errno.h> /* ENOENT */
|
||||
#include <sys/stat.h> /* fstat() */
|
||||
#include <fcntl.h> /* open() */
|
||||
#include <ctype.h>
|
||||
|
||||
#if defined(sun) || defined(__sun)
|
||||
# include <sys/systeminfo.h> /* sysinfo() */
|
||||
#else
|
||||
#include <sys/sysinfo.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h> /* stat() */
|
||||
#include <sys/wait.h> /* wait() */
|
||||
#include <unistd.h> /* execv(), unlink(), access() */
|
||||
#include <vroot/report.h> /* report_dependency(), get_report_file() */
|
||||
|
||||
#include <libintl.h> // gettext()
|
||||
|
||||
#include <comp/progname.h>
|
||||
|
||||
// From read2.cc
|
||||
extern Name normalize_name(register wchar_t *name_string, register int length);
|
||||
|
||||
|
@ -69,7 +78,7 @@ extern void job_adjust_fini();
|
|||
#define LD_SUPPORT_ENV_VAR_32 "SGS_SUPPORT_32"
|
||||
#define LD_SUPPORT_ENV_VAR_64 "SGS_SUPPORT_64"
|
||||
#define LD_SUPPORT_MAKE_LIB "libmakestate.so.1"
|
||||
#ifdef __i386
|
||||
#if defined(__i386) || defined(__x86_64__)
|
||||
#define LD_SUPPORT_MAKE_ARCH "i386"
|
||||
#elif __sparc
|
||||
#define LD_SUPPORT_MAKE_ARCH "sparc"
|
||||
|
@ -197,7 +206,11 @@ main(int argc, char *argv[])
|
|||
|
||||
struct stat out_stat, err_stat;
|
||||
hostid = gethostid();
|
||||
#if defined(sun) || defined(__sun)
|
||||
bsd_signals();
|
||||
#else
|
||||
// XXX necessary on linux?
|
||||
#endif
|
||||
|
||||
(void) setlocale(LC_ALL, "");
|
||||
|
||||
|
@ -475,7 +488,11 @@ main(int argc, char *argv[])
|
|||
/*
|
||||
* Enable interrupt handler for alarms
|
||||
*/
|
||||
#if defined(sun) || defined(__sun)
|
||||
(void) bsd_signal(SIGALRM, (SIG_PF)doalarm);
|
||||
#else
|
||||
(void) bsd_signal(SIGALRM, doalarm);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Check if make should report
|
||||
|
@ -1596,7 +1613,13 @@ make_install_prefix(void)
|
|||
char origin[PATH_MAX];
|
||||
char *dir;
|
||||
|
||||
if ((ret = readlink("/proc/self/path/a.out", origin,
|
||||
if ((ret = readlink(
|
||||
#if defined(sun) || defined(__sun)
|
||||
"/proc/self/path/a.out",
|
||||
#else
|
||||
"/proc/self/exe",
|
||||
#endif
|
||||
origin,
|
||||
PATH_MAX - 1)) < 0)
|
||||
fatal("failed to read origin from /proc\n");
|
||||
|
||||
|
|
|
@ -46,6 +46,10 @@
|
|||
#include <stdarg.h> /* va_list, va_start(), va_end() */
|
||||
#include <vroot/report.h> /* SUNPRO_DEPENDENCIES */
|
||||
#include <libintl.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <comp/progname.h>
|
||||
|
||||
extern void job_adjust_fini();
|
||||
|
||||
|
|
|
@ -46,8 +46,11 @@
|
|||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <netdb.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
#include <libintl.h>
|
||||
|
||||
#include <comp/namelen.h>
|
||||
|
||||
|
||||
/*
|
||||
|
@ -252,7 +255,12 @@ execute_parallel(Property line, Boolean waitflg, Boolean local)
|
|||
#include <sys/ipc.h> /* ftok() */
|
||||
#include <sys/shm.h> /* shmget(), shmat(), shmdt(), shmctl() */
|
||||
#include <semaphore.h> /* sem_init(), sem_trywait(), sem_post(), sem_destroy() */
|
||||
#if defined(sun) || defined(__sun)
|
||||
#include <sys/loadavg.h> /* getloadavg() */
|
||||
#else
|
||||
#include <stdlib.h> // getloadavg()
|
||||
#define LOADAVG_1MIN 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* adjust_pmake_max_jobs (int pmake_max_jobs)
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include <unistd.h> /* read(), unlink() */
|
||||
#include <libintl.h>
|
||||
|
||||
#include <comp/progname.h>
|
||||
|
||||
/*
|
||||
* typedefs & structs
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
#include <stdarg.h> /* va_list, va_start(), va_end() */
|
||||
#include <libintl.h>
|
||||
|
||||
#include <comp/progname.h>
|
||||
|
||||
/*
|
||||
* Defined macros
|
||||
*/
|
||||
|
|
|
@ -39,6 +39,11 @@
|
|||
#include <errno.h> /* errno */
|
||||
#include <locale.h> /* MB_CUR_MAX */
|
||||
|
||||
#if defined(sun) || defined(__sun)
|
||||
#else
|
||||
#include <libintl.h> // gettext()
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Defined macros
|
||||
*/
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include <signal.h>
|
||||
|
||||
#if defined(sun) || defined(__sun)
|
||||
|
||||
#ifndef __cplusplus
|
||||
typedef void (*SIG_PF) (int);
|
||||
|
@ -45,3 +46,5 @@ extern void (*bsd_signal(int, void (*) (int))) (int);
|
|||
extern void bsd_signals(void);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -294,7 +294,11 @@ extern long int hostid;
|
|||
* Declarations of system defined variables
|
||||
*/
|
||||
/* On linux this variable is defined in 'signal.h' */
|
||||
#if defined(sun) || defined(__sun)
|
||||
extern char *sys_siglist[];
|
||||
#else
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Declarations of system supplied functions
|
||||
|
@ -353,7 +357,9 @@ extern wchar_t *getmem_wc(register int size);
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#if defined(sun) || defined(__sun)
|
||||
extern char *getwd(char *);
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -36,6 +36,9 @@
|
|||
#include <errno.h> /* errno */
|
||||
|
||||
#include <wctype.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include <comp/timestruc_t.h>
|
||||
|
||||
/*
|
||||
* A type and some utilities for boolean values
|
||||
|
@ -861,7 +864,12 @@ extern Boolean do_not_exec_rule; /* `-n' */
|
|||
extern Boolean dollarget_seen;
|
||||
extern Boolean dollarless_flag;
|
||||
extern Name dollarless_value;
|
||||
// On Linux, environ is declared with C linkage in unistd.h
|
||||
// if _GNU_SOURCE is defined. Declaring it with C linkage here
|
||||
// should also be fine under Solaris.
|
||||
extern "C" {
|
||||
extern char **environ;
|
||||
}
|
||||
extern Envvar envvar;
|
||||
extern int exit_status;
|
||||
extern wchar_t *file_being_read;
|
||||
|
|
|
@ -93,7 +93,13 @@ redirect_io(char *stdout_file, char *stderr_file)
|
|||
{
|
||||
int i;
|
||||
|
||||
#if defined(sun) || defined(__sun)
|
||||
(void) closefrom(3);
|
||||
#else
|
||||
// XXX not available on Linux
|
||||
// if necessary, could provide a compatibility function that
|
||||
// iterates over /proc/$(getpid())/fd ...
|
||||
#endif
|
||||
if ((i = my_open(stdout_file,
|
||||
O_WRONLY | O_CREAT | O_TRUNC | O_DSYNC,
|
||||
S_IREAD | S_IWRITE)) < 0) {
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include <sys/wait.h> /* wait() */
|
||||
|
||||
#include <string.h> /* strerror() */
|
||||
#include <unistd.h>
|
||||
#include <libintl.h>
|
||||
|
||||
|
||||
|
@ -271,16 +272,33 @@ void
|
|||
enable_interrupt(register void (*handler) (int))
|
||||
{
|
||||
if (sigivalue != SIG_IGN) {
|
||||
#if defined(sun) || defined(__sun)
|
||||
(void) bsd_signal(SIGINT, (SIG_PF) handler);
|
||||
#else
|
||||
(void) bsd_signal(SIGINT, handler);
|
||||
#endif
|
||||
}
|
||||
if (sigqvalue != SIG_IGN) {
|
||||
#if defined(sun) || defined(__sun)
|
||||
(void) bsd_signal(SIGQUIT, (SIG_PF) handler);
|
||||
#else
|
||||
(void) bsd_signal(SIGQUIT, handler);
|
||||
#endif
|
||||
}
|
||||
if (sigtvalue != SIG_IGN) {
|
||||
#if defined(sun) || defined(__sun)
|
||||
(void) bsd_signal(SIGTERM, (SIG_PF) handler);
|
||||
#else
|
||||
(void) bsd_signal(SIGTERM, handler);
|
||||
#endif
|
||||
}
|
||||
if (sighvalue != SIG_IGN) {
|
||||
#if defined(sun) || defined(__sun)
|
||||
(void) bsd_signal(SIGHUP, (SIG_PF) handler);
|
||||
#else
|
||||
(void) bsd_signal(SIGHUP, handler);
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,10 +36,12 @@
|
|||
#include <errno.h> /* errno */
|
||||
#include <libintl.h>
|
||||
|
||||
#if defined(sun) || defined(__sun)
|
||||
extern char *sys_errlist[];
|
||||
extern int sys_nerr;
|
||||
#endif
|
||||
|
||||
static void file_lock_error(char *msg, char *file, char *str, int arg1, int arg2);
|
||||
static void file_lock_error(char *msg, char *file, char *str, const char *arg1, const char *arg2);
|
||||
|
||||
#define BLOCK_INTERUPTS sigfillset(&newset) ; \
|
||||
sigprocmask(SIG_SETMASK, &newset, &oldset)
|
||||
|
@ -109,7 +111,7 @@ file_lock(char *name, char *lockname, int *file_locked, int timeout)
|
|||
|
||||
if (errno != EEXIST) {
|
||||
file_lock_error(msg, name, (char *)"symlink(%s, %s)",
|
||||
(int) name, (int) lockname);
|
||||
name, lockname);
|
||||
fprintf(stderr, "%s", msg);
|
||||
return errno;
|
||||
}
|
||||
|
@ -157,7 +159,7 @@ file_lock(char *name, char *lockname, int *file_locked, int timeout)
|
|||
* Format a message telling why the lock could not be created.
|
||||
*/
|
||||
static void
|
||||
file_lock_error(char *msg, char *file, char *str, int arg1, int arg2)
|
||||
file_lock_error(char *msg, char *file, char *str, const char *arg1, const char *arg2)
|
||||
{
|
||||
int len;
|
||||
|
||||
|
|
Loading…
Reference in a new issue