Ignore:
Timestamp:
Oct 1, 2011, 9:49:54 PM (14 years ago)
Author:
bird
Message:

Applied modified patches for Haiku support from Mike Smith.

Location:
trunk/src/kmk/kmkbuiltin
Files:
7 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/kmkbuiltin/chmod.c

    r2466 r2546  
    5353#include <stdlib.h>
    5454#include <string.h>
    55 #ifdef _MSC_VER
     55#ifndef _MSC_VER
    5656# include <unistd.h>
    5757#else
     
    6060#ifdef __sun__
    6161# include "solfakes.h"
     62#endif
     63#ifdef __HAIKU__
     64# include "haikufakes.h"
    6265#endif
    6366#include "getopt.h"
  • trunk/src/kmk/kmkbuiltin/cp_utils.c

    r2466 r2546  
    3636#endif /* not lint */
    3737
     38#define MSC_DO_64_BIT_IO
    3839#include "config.h"
    3940#ifndef _MSC_VER
     
    5354#include <stdlib.h>
    5455#include <signal.h>
    55 #include <sysexits.h>
     56#ifndef __HAIKU__
     57# include <sysexits.h>
     58#endif
    5659#include <unistd.h>
    5760#ifdef __sun__
    5861# include "solfakes.h"
    5962#endif
     63#ifdef __HAIKU__
     64# include "haikufakes.h"
     65#endif
    6066#ifdef _MSC_VER
    61 # define MSC_DO_64_BIT_IO
    6267# include "mscfakes.h"
    6368#else
  • trunk/src/kmk/kmkbuiltin/fts.c

    r2203 r2546  
    7676
    7777#if ! HAVE_NBTOOL_CONFIG_H
    78 # if !defined(__sun__) && !defined(__gnu_linux__)
     78# if !defined(__sun__) && !defined(__gnu_linux__) && !defined(__HAIKU__)
    7979#  define HAVE_STRUCT_DIRENT_D_NAMLEN 1
    8080# endif
  • trunk/src/kmk/kmkbuiltin/haikufakes.c

    r2545 r2546  
    11/* $Id$ */
    22/** @file
    3  * Fake Unix stuff for Solaris.
     3 * Fake Unix/BSD stuff for Haiku.
    44 */
    55
     
    3333#include <stdlib.h>
    3434#include <sys/stat.h>
    35 #include "solfakes.h"
     35#include "haikufakes.h"
    3636
    3737
    38 int asprintf(char **strp, const char *fmt, ...)
    39 {
    40     int rc;
    41     va_list va;
    42     va_start(va, fmt);
    43     rc = vasprintf(strp, fmt, va);
    44     va_end(va);
    45     return rc;
    46 }
    47 
    48 
    49 int vasprintf(char **strp, const char *fmt, va_list va)
    50 {
    51     int rc;
    52     char *psz;
    53     size_t cb = 1024;
    54 
    55     *strp = NULL;
    56     for (;;)
    57     {
    58         va_list va2;
    59 
    60         psz = malloc(cb);
    61         if (!psz)
    62             return -1;
    63 
    64 #ifdef va_copy
    65         va_copy(va2, va);
    66         rc = snprintf(psz, cb, fmt, va2);
    67         va_end(va2);
    68 #else
    69         va2 = va;
    70         rc = snprintf(psz, cb, fmt, va2);
    71 #endif
    72         if (rc < 0 || (size_t)rc < cb)
    73             break;
    74         cb *= 2;
    75         free(psz);
    76     }
    77 
    78     *strp = psz;
    79     return rc;
    80 }
    81 
    82 
    83 
    84 int sol_lchmod(const char *pszPath, mode_t mode)
     38int haiku_lchmod(const char *pszPath, mode_t mode)
    8539{
    8640    /*
  • trunk/src/kmk/kmkbuiltin/haikufakes.h

    r2545 r2546  
    11/* $Id$ */
    22/** @file
    3  * Unix fakes for MSC.
     3 * Unix/BSD fakes for Haiku.
    44 */
    55
     
    2424 */
    2525
    26 #ifndef ___mscfakes_h
    27 #define ___mscfakes_h
    28 #ifdef _MSC_VER
    29 
    30 #include <io.h>
    31 #include <direct.h>
    32 #include <time.h>
    33 #include <stdarg.h>
    34 #include <malloc.h>
    35 #include "getopt.h"
    36 
    37 #if defined(MSC_DO_64_BIT_IO) && _MSC_VER >= 1400 /* We want 64-bit file lengths here when possible. */
    38 # define off_t __int64
    39 # define stat  _stat64
    40 # define fstat _fstat64
    41 # define lseek _lseeki64
    42 #else
    43 # undef stat
    44 # define stat(_path, _st) my_other_stat(_path, _st)
    45 extern int my_other_stat(const char *, struct stat *);
    46 #endif
    47 
    48 
    49 
    50 #ifndef S_ISDIR
    51 # define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
    52 #endif
    53 #ifndef S_ISREG
    54 # define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
    55 #endif
    56 #define S_ISLNK(m)  0
    57 #define S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
    58 #define S_IXUSR _S_IEXEC
    59 #define S_IWUSR _S_IWRITE
    60 #define S_IRUSR _S_IREAD
    61 #define S_IRWXG 0000070
    62 #define S_IRGRP 0000040
    63 #define S_IWGRP 0000020
    64 #define S_IXGRP 0000010
    65 #define S_IRWXO 0000007
    66 #define S_IROTH 0000004
    67 #define S_IWOTH 0000002
    68 #define S_IXOTH 0000001
    69 #define S_ISUID 0004000
    70 #define S_ISGID 0002000
    71 #define ALLPERMS 0000777
    72 
    73 #undef  PATH_MAX
    74 #define PATH_MAX   _MAX_PATH
    75 #undef  MAXPATHLEN
    76 #define MAXPATHLEN _MAX_PATH
     26#ifndef ___haikufakes_h
     27#define ___haikufakes_h
    7728
    7829#define EX_OK 0
     
    8031#define EX_NOUSER 1
    8132#define EX_USAGE 1
     33#define EX_TEMPFAIL 1
     34#define EX_SOFTWARE 1
    8235
    83 #define STDIN_FILENO 0
    84 #define STDOUT_FILENO 1
    85 #define STDERR_FILENO 2
     36#define lutimes(path, tvs) utimes(path, tvs)
     37#define lchmod             haiku_lchmod
    8638
    87 #define F_OK 0
    88 #define X_OK 1
    89 #define W_OK 2
    90 #define R_OK 4
    91 
    92 #define EFTYPE EINVAL
    93 
    94 #define _PATH_DEVNULL "/dev/null"
    95 
    96 #ifndef MAX
    97 # define MAX(a,b) ((a) >= (b) ? (a) : (b))
    9839#endif
    9940
    100 typedef int mode_t;
    101 typedef unsigned short nlink_t;
    102 #if 0 /* found in config.h */
    103 typedef unsigned short uid_t;
    104 typedef unsigned short gid_t;
    105 #endif
    106 typedef long ssize_t;
    107 typedef unsigned long u_long;
    108 typedef unsigned int u_int;
    109 typedef unsigned short u_short;
    110 
    111 #ifndef timerisset
    112 struct timeval
    113 {
    114     long tv_sec;
    115     long tv_usec;
    116 };
    117 #endif
    118 
    119 struct iovec
    120 {
    121     char *iov_base;
    122     size_t iov_len;
    123 };
    124 
    125 typedef __int64 intmax_t;
    126 #if 0 /* found in config.h */
    127 typedef unsigned __int64 uintmax_t;
    128 #endif
    129 
    130 #define chown(path, uid, gid) 0         /** @todo implement fchmod! */
    131 char *dirname(char *path);
    132 #define fsync(fd)  0
    133 #define fchown(fd,uid,gid) 0
    134 #define fchmod(fd, mode) 0              /** @todo implement fchmod! */
    135 #define geteuid()  0
    136 #define getegid()  0
    137 #define lstat(path, s) stat(path, s)
    138 int lchmod(const char *path, mode_t mode);
    139 int msc_chmod(const char *path, mode_t mode);
    140 #define chmod msc_chmod
    141 #define lchown(path, uid, gid) chown(path, uid, gid)
    142 #define lutimes(path, tvs) utimes(path, tvs)
    143 int link(const char *pszDst, const char *pszLink);
    144 int mkdir_msc(const char *path, mode_t mode);
    145 #define mkdir(path, mode) mkdir_msc(path, mode)
    146 #define mkfifo(path, mode) -1
    147 #define mknod(path, mode, devno) -1
    148 int mkstemp(char *temp);
    149 #define readlink(link, buf, size) -1
    150 #define reallocf(old, size) realloc(old, size)
    151 int rmdir_msc(const char *path);
    152 #define rmdir(path) rmdir_msc(path)
    153 intmax_t strtoimax(const char *nptr, char **endptr, int base);
    154 uintmax_t strtoumax(const char *nptr, char **endptr, int base);
    155 #define strtoll(a,b,c) strtoimax(a,b,c)
    156 #define strtoull(a,b,c) strtoumax(a,b,c)
    157 int asprintf(char **strp, const char *fmt, ...);
    158 int vasprintf(char **strp, const char *fmt, va_list ap);
    159 #if _MSC_VER < 1400
    160 int snprintf(char *buf, size_t size, const char *fmt, ...);
    161 #else
    162 #define snprintf _snprintf
    163 #endif
    164 int symlink(const char *pszDst, const char *pszLink);
    165 int utimes(const char *pszPath, const struct timeval *paTimes);
    166 int writev(int fd, const struct iovec *vector, int count);
    167 
    168 #endif /* _MSC_VER */
    169 #endif
    170 
  • trunk/src/kmk/kmkbuiltin/install.c

    r2543 r2546  
    5353#  include <sys/mman.h>
    5454# endif
    55 # include <sys/mount.h>
     55# ifndef __HAIKU__
     56#  include <sys/mount.h>
     57# endif
    5658# include <sys/wait.h>
    5759# include <sys/time.h>
     
    6971#include <stdlib.h>
    7072#include <string.h>
    71 #include <sysexits.h>
     73#ifndef __HAIKU__
     74# include <sysexits.h>
     75#endif
    7276#include <unistd.h>
    7377#if defined(__EMX__) || defined(_MSC_VER)
     
    8084#ifdef _MSC_VER
    8185# include "mscfakes.h"
     86#endif
     87#ifdef __HAIKU__
     88# include "haikufakes.h"
    8289#endif
    8390#include "kmkbuiltin.h"
  • trunk/src/kmk/kmkbuiltin/mkdir.c

    r2466 r2546  
    5454#include <stdlib.h>
    5555#include <string.h>
    56 #include <sysexits.h>
     56#ifndef __HAIKU__
     57# include <sysexits.h>
     58#endif
    5759#include <unistd.h>
    5860#ifdef HAVE_ALLOCA_H
     
    6062#endif
    6163#include "getopt.h"
     64#ifdef __HAIKU__
     65# include "haikufakes.h"
     66#endif
    6267#ifdef _MSC_VER
    6368# include <malloc.h>
  • trunk/src/kmk/kmkbuiltin/mv.c

    r2421 r2546  
    5656# include <sys/time.h>
    5757# include <sys/wait.h>
    58 # include <sys/mount.h>
     58# ifndef __HAIKU__
     59#  include <sys/mount.h>
     60# endif
    5961#endif
    6062#include <sys/stat.h>
     
    7072#include <stdlib.h>
    7173#include <string.h>
    72 #include <sysexits.h>
     74#ifndef __HAIKU__
     75# include <sysexits.h>
     76#endif
    7377#include <unistd.h>
    7478#include "getopt.h"
    7579#ifdef __sun__
    7680# include "solfakes.h"
     81#endif
     82#ifdef __HAIKU__
     83# include "haikufakes.h"
    7784#endif
    7885#ifdef _MSC_VER
  • trunk/src/kmk/kmkbuiltin/rm.c

    r2466 r2546  
    4444#include "config.h"
    4545#include <sys/stat.h>
    46 #ifndef _MSC_VER
     46#if !defined(_MSC_VER) && !defined(__HAIKU__)
    4747# include <sys/param.h>
    4848# include <sys/mount.h>
     
    5858#include <stdlib.h>
    5959#include <string.h>
    60 #include <sysexits.h>
     60#ifndef __HAIKU__
     61# include <sysexits.h>
     62#endif
    6163#include <unistd.h>
    6264#include <ctype.h>
    6365#include "getopt.h"
     66#ifdef __HAIKU__
     67# include "haikufakes.h"
     68#endif
    6469#ifdef _MSC_VER
    6570# include "mscfakes.h"
Note: See TracChangeset for help on using the changeset viewer.