summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-05-27 15:30:59 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-05-27 15:31:42 +0100
commit4aa29841f7b234c0b428dd46b124226fd69bb91f (patch)
treecdc66eaddf3dd7748ca15ec925ee56bf3dd91013
parentd6ce6a8cd541d21cb6fe5bed910238c0cc1fdd00 (diff)
elput - it seems not everyone has major and minor macros defined
so handle those cases and provide some implementation for those, otherwise use the macros.
-rw-r--r--src/lib/elput/elput_logind.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/lib/elput/elput_logind.c b/src/lib/elput/elput_logind.c
index c57b2e5611..02e53517f7 100644
--- a/src/lib/elput/elput_logind.c
+++ b/src/lib/elput/elput_logind.c
@@ -1,6 +1,19 @@
1#include "elput_private.h" 1#include "elput_private.h"
2 2
3#ifdef HAVE_SYSTEMD 3#ifdef HAVE_SYSTEMD
4
5# ifdef major
6# define MAJOR(x) major(x)
7# else
8# define MAJOR(x) ((((x) >> 8) & 0xfff) | (((x) >> 32) & ~0xfff))
9# endif
10
11# ifdef minor
12# define MINOR(x) minor(x)
13# else
14# define MAJOR(x) (((x) & 0xff) | (((x) >> 12) & ~0xff))
15# endif
16
4static Eina_Module *_libsystemd = NULL; 17static Eina_Module *_libsystemd = NULL;
5static Eina_Bool _libsystemd_broken = EINA_FALSE; 18static Eina_Bool _libsystemd_broken = EINA_FALSE;
6 19
@@ -673,7 +686,7 @@ _logind_open_async(Elput_Manager *em, const char *path, int flags)
673 if ((stat(path, &st) < 0) || (!S_ISCHR(st.st_mode))) 686 if ((stat(path, &st) < 0) || (!S_ISCHR(st.st_mode)))
674 _logind_pipe_write_fd(em, fd); 687 _logind_pipe_write_fd(em, fd);
675 else 688 else
676 _logind_device_take_async(em, flags, major(st.st_rdev), minor(st.st_rdev)); 689 _logind_device_take_async(em, flags, MAJOR(st.st_rdev), MINOR(st.st_rdev));
677} 690}
678 691
679static int 692static int
@@ -688,10 +701,10 @@ _logind_open(Elput_Manager *em, const char *path, int flags)
688 701
689 if (!S_ISCHR(st.st_mode)) return -1; 702 if (!S_ISCHR(st.st_mode)) return -1;
690 703
691 fd = _logind_device_take(em, major(st.st_rdev), minor(st.st_rdev)); 704 fd = _logind_device_take(em, MAJOR(st.st_rdev), MINOR(st.st_rdev));
692 if (fd < 0) return fd; 705 if (fd < 0) return fd;
693 706
694 if (major(st.st_rdev) == 226) //DRM_MAJOR 707 if (MAJOR(st.st_rdev) == 226) //DRM_MAJOR
695 em->drm_opens++; 708 em->drm_opens++;
696 709
697 fl = fcntl(fd, F_GETFL); 710 fl = fcntl(fd, F_GETFL);
@@ -707,7 +720,7 @@ _logind_open(Elput_Manager *em, const char *path, int flags)
707 720
708err: 721err:
709 close(fd); 722 close(fd);
710 _logind_device_release(em, major(st.st_rdev), minor(st.st_rdev)); 723 _logind_device_release(em, MAJOR(st.st_rdev), MINOR(st.st_rdev));
711 return -1; 724 return -1;
712} 725}
713 726
@@ -723,7 +736,7 @@ _logind_close(Elput_Manager *em, int fd)
723 736
724 if (!S_ISCHR(st.st_mode)) return; 737 if (!S_ISCHR(st.st_mode)) return;
725 738
726 _logind_device_release(em, major(st.st_rdev), minor(st.st_rdev)); 739 _logind_device_release(em, MAJOR(st.st_rdev), MINOR(st.st_rdev));
727} 740}
728 741
729static Eina_Bool 742static Eina_Bool