Skip to content

Commit

Permalink
Merge pull request #114 from Clozure/freebsd-mtim
Browse files Browse the repository at this point in the history
FreeBSD 12 updates
  • Loading branch information
xrme authored Mar 15, 2018
2 parents 31a25ea + 7e15285 commit e710ffa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 118 deletions.
8 changes: 4 additions & 4 deletions level-1/linux-files.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -391,17 +391,17 @@ given is that of a group to which the current user belongs."
(pref stat :stat.st_mode)
(pref stat :stat.st_size)
#+android-target (pref stat :stat.st_mtime)
#+(or (and linux-target (not android-target)) solaris-target)
#+(or freebsd-target (and linux-target (not android-target)) solaris-target)
(pref stat :stat.st_mtim.tv_sec)
#-(or linux-target solaris-target)
#-(or freebsd-target linux-target solaris-target)
(pref stat :stat.st_mtimespec.tv_sec)
(pref stat :stat.st_ino)
(pref stat :stat.st_uid)
(pref stat :stat.st_blksize)
#+(or linux-target solaris-target)
#+(or freebsd-target linux-target solaris-target)
(round (pref stat #-android-target :stat.st_mtim.tv_nsec
#+android-target :stat.st_mtime_nsec) 1000)
#-(or linux-target solaris-target)
#-(or freebsd-target linux-target solaris-target)
(round (pref stat :stat.st_mtimespec.tv_nsec) 1000)
(pref stat :stat.st_gid)
(pref stat :stat.st_dev)
Expand Down
114 changes: 0 additions & 114 deletions lisp-kernel/unix-calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,6 @@
#endif
#include <errno.h>
#include <unistd.h>
#if __FreeBSD_version >= 1200031
/*
* ino_t, dev_t, nlink_t were extended to 64 bits (thereby changing
* struct stat). struct dirent changed also.
*
* Make the old versions available as freebsd11_stat and freebsd11_dirent.
* XXX - this should go away when FreeBSD 12 headers are generated
*/
#define _WANT_FREEBSD11_STAT
#define _WANT_FREEBSD11_DIRENT
#include <string.h>
#endif
#include <sys/stat.h>
#include <dirent.h>
#include <sys/syscall.h>
Expand Down Expand Up @@ -96,81 +84,6 @@ lisp_ftruncate(int fd, off_t length)
return ftruncate(fd,length);
}

#if __FreeBSD_version >= 1200031
/*
* struct stat has changed. As a temporary workaround until
* we can generate headers for FreeBSD 12, return stat(2) data in
* the old version of struct stat that the lisp expects.
*/
void
populate_old_stat(struct stat *sb, struct freebsd11_stat *sb11)
{
memset(sb11, 0, sizeof(*sb11));
sb11->st_dev = sb->st_dev;
sb11->st_ino = sb->st_ino;
sb11->st_mode = sb->st_mode;
sb11->st_nlink = sb->st_nlink;
sb11->st_uid = sb->st_uid;
sb11->st_gid = sb->st_gid;
sb11->st_rdev = sb->st_rdev;
sb11->st_atim = sb->st_atim;
sb11->st_mtim = sb->st_mtim;
sb11->st_ctim = sb->st_ctim;
sb11->st_size = sb->st_size;
sb11->st_blocks = sb->st_blocks;
sb11->st_blksize = sb->st_blksize;
sb11->st_flags = sb->st_flags;
sb11->st_gen = sb->st_gen;
sb11->st_birthtim = sb->st_birthtim;
}

int
lisp_stat(char *path, void *buf)
{
struct stat sb;
int ret;

ret = stat(path, &sb);
if (ret == 0) {
populate_old_stat(&sb, buf);
return 0;
} else {
return -1;
}
}

int
lisp_fstat(int fd, void *buf)
{
struct stat sb;
int ret;

ret = fstat(fd, &sb);
if (ret == 0) {
populate_old_stat(&sb, buf);
return 0;
} else {
return -1;
}
}

int
lisp_lstat(char *path, void *buf)
{
struct stat sb;
int ret;

ret = lstat(path, &sb);
if (ret == 0) {
populate_old_stat(&sb, buf);
return 0;
} else {
return -1;
}
}

#else

int
lisp_stat(char *path, void *buf)
{
Expand All @@ -188,7 +101,6 @@ lisp_lstat(char *path, void *buf)
{
return lstat(path, buf);
}
#endif

int
lisp_futex(int *uaddr, int op, int val, void *timeout, int *uaddr2, int val3)
Expand All @@ -207,37 +119,11 @@ lisp_opendir(char *path)
return opendir(path);
}

#if __FreeBSD_version >= 1200031
/*
* struct dirent has changed. Lisp only cares about :dirent.d_name,
* so make that available in the old struct dirent.
* Again, this will all go away when we generate new interfaces for
* FreeBSD 12.
*/
static __thread struct freebsd11_dirent old_dirent;

struct freebsd11_dirent *
lisp_readdir(DIR *dir)
{
struct dirent *dp;
struct freebsd11_dirent d11;

dp = readdir(dir);
if (dp != NULL) {
memset(&old_dirent, 0, sizeof(old_dirent));
strcpy(old_dirent.d_name, dp->d_name);
return &old_dirent;
} else {
return NULL;
}
}
#else
struct dirent *
lisp_readdir(DIR *dir)
{
return readdir(dir);
}
#endif

int
lisp_closedir(DIR *dir)
Expand Down

0 comments on commit e710ffa

Please sign in to comment.