Changeset 1403 for trunk/lang


Ignore:
Timestamp:
Apr 17, 2009 10:18:03 AM (15 years ago)
Author:
gah
Message:

Fix for no sysinfo on OSX

Location:
trunk/lang/tcl/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lang/tcl/src/Makefile.in

    r1383 r1403  
    3131
    3232INCLUDES        = -I$(srcdir) \
     33                  -I../../../src/core \
    3334                  -I$(srcdir)/../../../src/core \
    3435                  -I$(includedir)
  • trunk/lang/tcl/src/RpSysinfo.c

    r1327 r1403  
    1313 * ======================================================================
    1414 */
     15#include "config.h"
    1516#include <tcl.h>
    1617#include <stdlib.h>
    1718#include <stddef.h>
    1819#include <string.h>
     20
     21static Tcl_CmdProc RpSysinfoCmd;
     22
     23
     24/*
     25 * ------------------------------------------------------------------------
     26 *  RpSysinfo_Init()
     27 *
     28 *  Called in Rappture_Init() to initialize the commands defined
     29 *  in this file.
     30 * ------------------------------------------------------------------------
     31 */
     32int
     33RpSysinfo_Init(interp)
     34    Tcl_Interp *interp;  /* interpreter being initialized */
     35{
     36    /* install the sysinfo command */
     37    Tcl_CreateCommand(interp, "::Rappture::sysinfo", RpSysinfoCmd,
     38        (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
     39
     40    return TCL_OK;
     41}
     42
     43#ifndef HAVE_SYSINFO
     44
     45static int
     46RpSysinfoCmd(cdata, interp, argc, argv)
     47    ClientData cdata;         /* not used */
     48    Tcl_Interp *interp;       /* interpreter handling this request */
     49    int argc;                 /* number of command line args */
     50    CONST84 char *argv[];     /* strings for command line args */
     51{
     52    Tcl_SetResult(interp, "command not implemented: no sysinfo", TCL_STATIC);
     53    return TCL_ERROR;
     54}
     55
     56#else
     57
     58#ifdef HAVE_SYS_SYSINFO_H
    1959#include <sys/sysinfo.h>
    20 
    21 static Tcl_CmdProc RpSysinfoCmd;
    22 static Tcl_Obj* RpSysinfoValue _ANSI_ARGS_((struct sysinfo *sinfo,
    23     int idx));
     60#endif  /* HAVE_SYS_SYSINFO_H */
    2461
    2562#define RP_SLOT_LONG   1
     
    2764#define RP_SLOT_USHORT 3
    2865#define RP_SLOT_LOAD   4
     66
     67struct rpSysinfoList {
     68    const char *name;           /* Name of this system parameter */
     69    int type;                   /* Parameter type (long, unsigned long,
     70                                 * etc.) */
     71    int offset;                 /* Offset into sysinfo struct */
     72};
    2973
    3074#ifdef offsetof
     
    3478#endif
    3579
    36 static struct rpSysinfoList {
    37     const char *name;           /* Name of this system parameter */
    38     int type;                   /* Parameter type (long, unsigned long,
    39                                  * etc.) */
    40     int offset;                 /* Offset into sysinfo struct */
    41 } RpSysinfoList [] = {
     80static struct rpSysinfoList RpSysinfoList [] = {
    4281    {"freeram",   RP_SLOT_ULONG,  Offset(struct sysinfo, freeram)},
    4382    {"freeswap",  RP_SLOT_ULONG,  Offset(struct sysinfo, freeswap)},
     
    5291};
    5392
    54 /*
    55  * ------------------------------------------------------------------------
    56  *  RpSysinfo_Init()
    57  *
    58  *  Called in Rappture_Init() to initialize the commands defined
    59  *  in this file.
    60  * ------------------------------------------------------------------------
    61  */
    62 int
    63 RpSysinfo_Init(interp)
    64     Tcl_Interp *interp;  /* interpreter being initialized */
    65 {
    66     /* install the sysinfo command */
    67     Tcl_CreateCommand(interp, "::Rappture::sysinfo", RpSysinfoCmd,
    68         (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
    69 
    70     return TCL_OK;
    71 }
     93static Tcl_Obj* RpSysinfoValue(struct sysinfo *sinfo, int idx);
    7294
    7395/*
     
    187209    return NULL;
    188210}
     211
     212#endif /*HAVE_SYSINFO*/
Note: See TracChangeset for help on using the changeset viewer.