diff --git a/bindings/perl/Sigar.pm b/bindings/perl/Sigar.pm index 452095fc..76b66aa1 100644 --- a/bindings/perl/Sigar.pm +++ b/bindings/perl/Sigar.pm @@ -40,27 +40,5 @@ else { sub NULL_HWADDR() { "00:00:00:00:00:00" } -sub IFF_UP() { 0x1 } - -sub IFF_BROADCAST() { 0x2 } - -sub IFF_DEBUG() { 0x4 } - -sub IFF_LOOPBACK() { 0x8 } - -sub IFF_POINTOPOINT() { 0x10 } - -sub IFF_NOTRAILERS() { 0x20 } - -sub IFF_RUNNING() { 0x40 } - -sub IFF_NOARP() { 0x80 } - -sub IFF_PROMISC() { 0x100 } - -sub IFF_ALLMULTI() { 0x200 } - -sub IFF_MULTICAST() { 0x800 } - 1; __END__ diff --git a/bindings/perl/Sigar.xs b/bindings/perl/Sigar.xs index a1e892ca..872c37c9 100644 --- a/bindings/perl/Sigar.xs +++ b/bindings/perl/Sigar.xs @@ -134,12 +134,34 @@ static int proc_env_getvalue(void *data, return SIGAR_OK; } +#define XS_SIGAR_CONST_IV(name) \ + (void)newCONSTSUB(stash, #name, newSViv(SIGAR_##name)) + +static void boot_Sigar_constants(pTHX) +{ + HV *stash = gv_stashpv("Sigar", TRUE); + XS_SIGAR_CONST_IV(IFF_UP); + XS_SIGAR_CONST_IV(IFF_BROADCAST); + XS_SIGAR_CONST_IV(IFF_DEBUG); + XS_SIGAR_CONST_IV(IFF_LOOPBACK); + XS_SIGAR_CONST_IV(IFF_POINTOPOINT); + XS_SIGAR_CONST_IV(IFF_NOTRAILERS); + XS_SIGAR_CONST_IV(IFF_RUNNING); + XS_SIGAR_CONST_IV(IFF_NOARP); + XS_SIGAR_CONST_IV(IFF_PROMISC); + XS_SIGAR_CONST_IV(IFF_ALLMULTI); + XS_SIGAR_CONST_IV(IFF_MULTICAST); +} + MODULE = Sigar PACKAGE = Sigar PROTOTYPES: disable INCLUDE: Sigar_generated.xs +BOOT: + boot_Sigar_constants(aTHX); + MODULE = Sigar PACKAGE = Sigar PREFIX = sigar_ Sigar