Skip to content

Commit

Permalink
Resolve android C type problems.
Browse files Browse the repository at this point in the history
Android doesn't use off_t where SBCL expects to find it, declare
things appropriately in struct stat, struct dirent.
  • Loading branch information
stassats committed Jun 1, 2014
1 parent e55432f commit 30d48e6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
21 changes: 15 additions & 6 deletions contrib/sb-posix/constants.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@
(:structure dirent
(#+(and linux largefile) "struct dirent64"
#-(and linux largefile) "struct dirent"
#-win32 (:ino-t ino "ino_t" "d_ino")
#-(or win32 android) (:ino-t ino "ino_t" "d_ino")
#+android ((unsigned 64) ino "unsigned long long" "d_ino")
(:c-string name "char *" "d_name"
;; FIXME: sunos should really have :distrust-length
;; t, but this is currently broken. -- Jim Wise 2010-08-31
Expand Down Expand Up @@ -310,21 +311,31 @@
(:structure alien-stat
("struct stat"
(mode-t mode "mode_t" "st_mode")
#-android
(ino-t ino "ino_t" "st_ino")
#+android
((unsigned 64) ino "unsigned long long" "st_ino")
;; Linux/MIPS uses unsigned long instead of dev_t here.
#-mips
#-(or mips android)
(dev-t dev "dev_t" "st_dev")
#+mips
((unsigned 32) dev "dev_t" "st_dev")
#+android
((unsigned 64) dev "unsigned long long" "st_dev")
(nlink-t nlink "nlink_t" "st_nlink")
(uid-t uid "uid_t" "st_uid")
;; Linux/MIPS uses unsigned long instead of dev_t here.
#-mips
#-(or mips android)
(dev-t rdev "dev_t" "st_rdev")
#+mips
((unsigned 32) rdev "dev_t" "st_rdev")
#+android
((unsigned 64) rdev "unsigned long long" "st_rdev")
(gid-t gid "gid_t" "st_gid")
#-android
(off-t size "off_t" "st_size")
#+android
((signed 64) size "long long" "st_size")
(time-t atime "time_t" "st_atime")
(time-t mtime "time_t" "st_mtime")
(time-t ctime "time_t" "st_ctime")))
Expand Down Expand Up @@ -649,6 +660,4 @@
log-info "LOG_INFO" "Log severity level denoting informational messages." t)
#-win32
(:integer
log-debug "LOG_DEBUG" "Log severity level denoting debugging information ." t)

)
log-debug "LOG_DEBUG" "Log severity level denoting debugging information ." t))
2 changes: 1 addition & 1 deletion src/code/unix.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ avoiding atexit(3) hooks, etc. Otherwise exit(2) is called."
(define-alien-type nil
(struct wrapped_stat
(st-dev wst-dev-t)
(st-ino ino-t)
(st-ino wst-ino-t)
(st-mode mode-t)
(st-nlink wst-nlink-t)
(st-uid wst-uid-t)
Expand Down
13 changes: 11 additions & 2 deletions src/runtime/wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,28 @@ typedef unsigned long aliased_dev_t;
typedef dev_t aliased_dev_t;
#endif

#if defined(LISP_FEATURE_LARGEFILE) || defined(LISP_FEATURE_DARWIN)
#ifdef LISP_FEATURE_ANDROID
typedef unsigned long long wst_ino_t;
typedef long long wst_off_t;
typedef unsigned long long wst_dev_t;
#elif defined(LISP_FEATURE_LARGEFILE) || defined(LISP_FEATURE_DARWIN)
typedef ino_t wst_ino_t;
typedef aliased_dev_t wst_dev_t;
typedef off_t wst_off_t;
#else
/* These wrappers shouldn't exist, and since pulling in runtime.h caused
* problems on Win32, we don't use the u32 typedef. */
typedef ino_t wst_ino_t;
typedef unsigned int wst_dev_t; /* since Linux dev_t can be 64 bits */
typedef unsigned int wst_off_t; /* since OpenBSD 2.8 st_size is 64 bits */
#endif

#ifdef LISP_FEATURE_OS_PROVIDES_BLKSIZE_T
typedef blksize_t wst_blksize_t;
typedef blkcnt_t wst_blkcnt_t;
#elif defined(LISP_FEATURE_ANDROID)
typedef unsigned long wst_blksize_t;
typedef unsigned long long wst_blkcnt_t;
#else
typedef unsigned long wst_blksize_t;
typedef unsigned long wst_blkcnt_t;
Expand Down Expand Up @@ -83,7 +92,7 @@ struct stat_wrapper {
* another entry for Dan Barlow's ongoing episodic rant about C
* header files, I guess.. -- WHN 2001-05-10 */
wst_dev_t wrapped_st_dev; /* device */
ino_t wrapped_st_ino; /* inode */
wst_ino_t wrapped_st_ino; /* inode */
mode_t wrapped_st_mode; /* protection */
wst_nlink_t wrapped_st_nlink; /* number of hard links */
wst_uid_t wrapped_st_uid; /* user ID of owner */
Expand Down
1 change: 1 addition & 0 deletions tools-for-build/grovel-headers.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ main(int argc, char *argv[])
DEFTYPE("uid-t", uid_t);
printf(";; Types in src/runtime/wrap.h. See that file for explantion.\n");
printf(";; Don't use these types for anything other than the stat wrapper.\n");
DEFTYPE("wst-ino-t", wst_ino_t);
DEFTYPE("wst-dev-t", wst_dev_t);
DEFTYPE("wst-off-t", wst_off_t);
DEFTYPE("wst-blksize-t", wst_blksize_t);
Expand Down

0 comments on commit 30d48e6

Please sign in to comment.