Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cdrwtool/cdrwtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@
#include <limits.h>

#include <sys/ioctl.h>
#if defined(__linux__)
#include <asm/param.h>

#include <linux/cdrom.h>
#else
#include "bswap.h"
#include "darwin/cdrom.h"
#endif

#include "cdrwtool.h"
#include "../mkudffs/mkudffs.h"
Expand Down
4 changes: 4 additions & 0 deletions cdrwtool/cdrwtool.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
#define _CDRWTOOL_H 1

#include <inttypes.h>
#if defined(__linux__)
#include <linux/cdrom.h>
#else
#include "darwin/cdrom.h"
#endif
#include "../include/libudffs.h"

/*
Expand Down
6 changes: 6 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ AC_SYS_LARGEFILE
dnl Checks for library functions.
AC_SUBST(LTLIBOBJS)

dnl Enable Darwin extensions
AC_CANONICAL_HOST
AS_CASE([$host_os],
[darwin*], [CPPFLAGS="${CPPFLAGS} -D_DARWIN_C_SOURCE"])
AM_CONDITIONAL(HAVE_DARWIN, test "${SYS}" = "darwin")

AC_CONFIG_FILES(Makefile libudffs/Makefile mkudffs/Makefile cdrwtool/Makefile pktsetup/Makefile udffsck/Makefile udfinfo/Makefile udflabel/Makefile wrudf/Makefile doc/Makefile)

AC_OUTPUT
15 changes: 15 additions & 0 deletions include/bswap.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
#include <inttypes.h>
#include <sys/types.h>

#if defined(HAVE_MACHINE_ENDIAN_H)
#include <machine/endian.h>
#endif
#ifdef HAVE_SYS_ISA_DEFS_H
#define __LITTLE_ENDIAN 1234
#define __BIG_ENDIAN 4321
Expand All @@ -42,6 +45,18 @@
#endif
#endif

/* macOS */
#ifdef __APPLE__
#define __LITTLE_ENDIAN LITTLE_ENDIAN
#define __BIG_ENDIAN BIG_ENDIAN
#define __BYTE_ORDER BYTE_ORDER
#if __BYTE_ORDER == BIG_ENDIAN
#define __BIG_ENDIAN_BITFIELD
#elif __BYTE_ORDER == LITTLE_ENDIAN
#define __LITTLE_ENDIAN_BITFIELD
#endif
#endif /* __APPLE__ */
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not invent new way for determining endiantity. We already use autoconf which has standard macros for it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's how it works without reshuffling too much the chain of ifdef'ed code.
You have to consider that I'm not actually determining there endianness, only perusing how it is pre-defined in the macOS-specific way (i.e., as in machine/endian.h). Indeed the right side of the defines (no double under-score) comes from the Darwin header.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Autoconf has macro AC_C_BIGENDIAN to check for endianity, see:
https://www.gnu.org/software/autoconf/manual/autoconf.html

There is absolutely no reason for adding new special ifdef for Apple systems as autoconf can handle it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried, but it does not work. The ifdef'ed HAVE_SYS_ISA_DEFS_H part is a bit non-standard and makes the following (ifdef APPLE) necessary. Again, consider that it is not determining endianness, only doing what you do under HAVE_SYS_ISA_DEFS_H (e.g., define the __*) which are not available anywhere on a Darwin system otherwise.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But why to use HAVE_SYS_ISA_DEFS_H? WORDS_BIGENDIAN should be defined only on big endian systems.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I did it in 0adadb6


#define constant_swab16(x) \
((uint16_t)((((uint16_t)(x) & 0x00FFU) << 8) | \
(((uint16_t)(x) & 0xFF00U) >> 8)))
Expand Down
Loading