import os
 import atexit
 import random
+import struct
 import sysv_ipc
 
 DEBUG = False
 
 atexit.register(final)
 
-# pylint: disable=c-extension-no-member, consider-using-with
+# pylint: disable=c-extension-no-member
 class PulseIn:
     """PulseIn Class to read PWM signals"""
 
                 "Message queue creation failed"
             ) from sysv_ipc.ExistentialError
 
+        # Check if OS is 64-bit
+        if struct.calcsize("P") * 8 == 64:
+            libgpiod_filename = "libgpiod_pulsein64"
+        else:
+            libgpiod_filename = "libgpiod_pulsein"
+
         dir_path = os.path.dirname(os.path.realpath(__file__))
         cmd = [
-            dir_path + "/libgpiod_pulsein",
+            dir_path + "/" + libgpiod_filename,
             "--pulses",
             str(maxlen),
             "--queue",