Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'jb49555_musl_fixes' into 'master'
Fix issues from arising from musl libc compatibility

See merge request mer-core/dsme!42
  • Loading branch information
spiiroin committed Sep 24, 2020
2 parents 94238c2 + a0a9f9b commit 9fec3af
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 21 deletions.
16 changes: 16 additions & 0 deletions .depend
Expand Up @@ -28,26 +28,30 @@ dsme/dsme-server.pic.o:\

dsme/dsme-wdd-wd.o:\
dsme/dsme-wdd-wd.c\
include/dsme/musl-compatibility.h\
dsme/dsme-rd-mode.h\
dsme/dsme-wdd-wd.h\
dsme/dsme-wdd.h\

dsme/dsme-wdd-wd.pic.o:\
dsme/dsme-wdd-wd.c\
include/dsme/musl-compatibility.h\
dsme/dsme-rd-mode.h\
dsme/dsme-wdd-wd.h\
dsme/dsme-wdd.h\

dsme/dsme-wdd.o:\
dsme/dsme-wdd.c\
include/dsme/logging.h\
include/dsme/musl-compatibility.h\
include/dsme/oom.h\
dsme/dsme-wdd-wd.h\
dsme/dsme-wdd.h\

dsme/dsme-wdd.pic.o:\
dsme/dsme-wdd.c\
include/dsme/logging.h\
include/dsme/musl-compatibility.h\
include/dsme/oom.h\
dsme/dsme-wdd-wd.h\
dsme/dsme-wdd.h\
Expand Down Expand Up @@ -146,6 +150,7 @@ modules/abootsettings.o:\
include/dsme/modulebase.h\
include/dsme/modules.h\
include/dsme/modules.h\
include/dsme/musl-compatibility.h\
modules/dbusproxy.h\
modules/dsme_dbus.h\

Expand All @@ -155,6 +160,7 @@ modules/abootsettings.pic.o:\
include/dsme/modulebase.h\
include/dsme/modules.h\
include/dsme/modules.h\
include/dsme/musl-compatibility.h\
modules/dbusproxy.h\
modules/dsme_dbus.h\

Expand Down Expand Up @@ -318,6 +324,7 @@ modules/heartbeat.pic.o:\

modules/iphb.o:\
modules/iphb.c\
include/dsme/musl-compatibility.h\
dsme/dsme-server.h\
dsme/dsme-wdd-wd.h\
dsme/utility.h\
Expand All @@ -333,6 +340,7 @@ modules/iphb.o:\

modules/iphb.pic.o:\
modules/iphb.c\
include/dsme/musl-compatibility.h\
dsme/dsme-server.h\
dsme/dsme-wdd-wd.h\
dsme/utility.h\
Expand Down Expand Up @@ -574,6 +582,7 @@ modules/thermalsensor_generic.o:\
modules/thermalsensor_generic.c\
include/dsme/logging.h\
include/dsme/modules.h\
include/dsme/musl-compatibility.h\
include/dsme/timers.h\
modules/dbusproxy.h\
modules/thermalmanager.h\
Expand All @@ -582,6 +591,7 @@ modules/thermalsensor_generic.pic.o:\
modules/thermalsensor_generic.c\
include/dsme/logging.h\
include/dsme/modules.h\
include/dsme/musl-compatibility.h\
include/dsme/timers.h\
modules/dbusproxy.h\
modules/thermalmanager.h\
Expand Down Expand Up @@ -629,13 +639,19 @@ modules/usbtracker.pic.o:\
modules/validatorlistener.o:\
modules/validatorlistener.c\
include/dsme/logging.h\
include/dsme/modulebase.h\
include/dsme/modules.h\
include/dsme/modules.h\
include/dsme/musl-compatibility.h\
modules/malf.h\

modules/validatorlistener.pic.o:\
modules/validatorlistener.c\
include/dsme/logging.h\
include/dsme/modulebase.h\
include/dsme/modules.h\
include/dsme/modules.h\
include/dsme/musl-compatibility.h\
modules/malf.h\

modules/vibrafeedback.o:\
Expand Down
1 change: 1 addition & 0 deletions Makefile.custom
Expand Up @@ -394,6 +394,7 @@ CLEAN_HEADERS += modules/isi_conf.h
CLEAN_HEADERS += include/dsme/oom.h
CLEAN_HEADERS += include/dsme/mainloop.h
CLEAN_HEADERS += include/dsme/timers.h
CLEAN_HEADERS += include/dsme/musl-compatibility.h

# Files with whitespace issues

Expand Down
2 changes: 0 additions & 2 deletions dsme/dsme-wdd-wd.h
Expand Up @@ -31,9 +31,7 @@

#include <stdbool.h>

#ifndef __GLIBC__
#include "../include/dsme/musl-compatibility.h"
#endif

// Period for kicking; i.e. how soon the quickest watchdog will bite.
// NOTE: This must be picked from the wd[] array in dsme-wdd-wd.c!
Expand Down
3 changes: 3 additions & 0 deletions include/dsme/modules.h
Expand Up @@ -27,8 +27,11 @@
#define DSME_MODULES_H

#include <dsme/messages.h>

#include <sys/types.h>

#include <stdbool.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
Expand Down
26 changes: 22 additions & 4 deletions include/dsme/musl-compatibility.h
@@ -1,10 +1,28 @@
/* Used to retry syscalls that can return EINTR. Taken from bionic unistd.h */
#ifndef TEMP_FAILURE_RETRY
#define TEMP_FAILURE_RETRY(exp) ({ \
#ifndef DSME_MUSL_COMPATIBILITY_H_
# define DSME_MUSL_COMPATIBILITY_H_

/* Whether __GLIBC__ gets defined when compiling against gnu libc,
* depends on what - if any - libc header files have been included
* so far. To be sure, include features.h that contains the define.
*/
# include <features.h>

/* Define equivalents for glibc macros that dsme sources are using,
* but are not defined in musl libc headers.
*/
# ifndef __GLIBC__

/* Used to retry syscalls that can return EINTR. Taken from bionic unistd.h
*/
# ifndef TEMP_FAILURE_RETRY
# define TEMP_FAILURE_RETRY(exp) ({ \
__typeof__(exp) _rc; \
do { \
_rc = (exp); \
} while (_rc == -1 && errno == EINTR); \
_rc; })
#endif
# endif

# endif /* not __GLIBC__ */

#endif /* DSME_MUSL_COMPATIBILITY_H_ */
6 changes: 2 additions & 4 deletions modules/abootsettings.c
Expand Up @@ -32,10 +32,6 @@
#include "../include/dsme/modulebase.h"
#include "../include/dsme/logging.h"

#ifndef __GLIBC__
#include "../include/dsme/temp-failure-retry.h"
#endif

#include <dsme/state.h>

#include <glib.h>
Expand All @@ -48,6 +44,8 @@
#include <fcntl.h>
#include <linux/fs.h>

#include "../include/dsme/musl-compatibility.h"

#define PFIX "abootsettings: "
// Device info magic string (from aboot)
#define DEVICE_MAGIC "ANDROID-BOOT!"
Expand Down
8 changes: 5 additions & 3 deletions modules/diskmonitor.c
Expand Up @@ -55,12 +55,14 @@
#include <time.h>
#include <mntent.h>

#include <glib.h>

/* musl-libc compatibility */
#include <features.h> // for __GLIBC__
#ifndef __GLIBC__
#include <paths.h>
# include <paths.h>
#endif

#include <glib.h>

/* ========================================================================= *
* TYPES
* ========================================================================= */
Expand Down
6 changes: 2 additions & 4 deletions modules/thermalsensor_generic.c
Expand Up @@ -32,10 +32,6 @@
#include "../include/dsme/timers.h"
#include "../include/dsme/logging.h"

#ifndef __GLIBC__
#include "../include/dsme/temp-failure-retry.h"
#endif

#include "dbusproxy.h"

/* ========================================================================= *
Expand All @@ -57,6 +53,8 @@

#include <glib.h>

#include "../include/dsme/musl-compatibility.h"

/* ========================================================================= *
* DIAGNOSTIC_LOGGING
* ========================================================================= */
Expand Down
2 changes: 2 additions & 0 deletions modules/upstart.c
Expand Up @@ -42,6 +42,8 @@
#include <sys/utsname.h>
#include <sys/time.h>

/* musl-libc compatibility */
#include <features.h> // for __GLIBC__
#ifndef __GLIBC__
# include <utmp.h>
# if defined _PATH_UTMP && !defined _PATH_UTMPX
Expand Down
5 changes: 1 addition & 4 deletions modules/validatorlistener.c
Expand Up @@ -36,10 +36,6 @@
#include "../include/dsme/logging.h"
#include "../include/dsme/modulebase.h"

#ifndef __GLIBC__
#include "../include/dsme/temp-failure-retry.h"
#endif

#include <string.h>
#include <stdio.h>
#include <stdlib.h>
Expand All @@ -50,6 +46,7 @@
#include <ctype.h>
#include <errno.h>

#include "../include/dsme/musl-compatibility.h"

#define DSME_STATIC_STRLEN(s) (sizeof(s) - 1)

Expand Down
1 change: 1 addition & 0 deletions test/dummy_bme.c
Expand Up @@ -28,6 +28,7 @@
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <stdint.h>

#include <sys/types.h>
#include <sys/time.h>
Expand Down

0 comments on commit 9fec3af

Please sign in to comment.