Check-in [bf927c2247]
Overview
SHA1:bf927c2247eaef5474908e986f9dbe4f1c8a692a
Date: 2017-09-12 19:41:40
User: rkeene
Comment:Added "adjtime" support
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2017-09-12
19:42
[32375279e7] TUAPI 0.12 (user: rkeene, tags: trunk, 0.12)
19:41
[bf927c2247] Added "adjtime" support (user: rkeene, tags: trunk)
2017-08-14
22:22
[23693dd526] Updated license information (user: rkeene, tags: trunk)
Changes

Modified tuapi.c from [7aa2faf93b] to [6f7b792413].

    28     28   #include <sys/prctl.h>
    29     29   #include <arpa/inet.h>
    30     30   #include <sys/socket.h>
    31     31   #include <sys/select.h>
    32     32   #include <sys/mount.h>
    33     33   #include <sys/types.h>
    34     34   #include <sys/ioctl.h>
           35  +#include <sys/timex.h>
    35     36   #include <sys/time.h>
    36     37   #include <sys/klog.h>
    37     38   #include <sys/swap.h>
    38     39   #include <sys/stat.h>
    39     40   #include <sys/wait.h>
    40     41   #include <sys/un.h>
    41     42   #include <stdlib.h>
................................................................................
  2514   2515   		Tcl_SetObjResult(interp, Tcl_NewStringObj(strerror(errno), -1));
  2515   2516   
  2516   2517   		return(TCL_ERROR);
  2517   2518   	}
  2518   2519   
  2519   2520   	return(TCL_OK);
  2520   2521   }
         2522  +
         2523  +static int tuapi_adjtime(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
         2524  +	struct timeval tv, oldTV;
         2525  +	Tcl_WideInt tv_sec_val, tv_usec_val;
         2526  +	int adjtime_ret, tcl_ret;
         2527  +
         2528  +	if (objc != 3) {
         2529  +		Tcl_SetObjResult(interp, Tcl_NewStringObj("wrong # args: should be \"::tuapi::syscall::adjtime seconds microseconds\"", -1));
         2530  +
         2531  +		return(TCL_ERROR);
         2532  +	}
         2533  +
         2534  +	tcl_ret = Tcl_GetWideIntFromObj(interp, objv[1], &tv_sec_val);
         2535  +	if (tcl_ret != TCL_OK) {
         2536  +		return(tcl_ret);
         2537  +	}
         2538  +
         2539  +	tcl_ret = Tcl_GetWideIntFromObj(interp, objv[2], &tv_usec_val);
         2540  +	if (tcl_ret != TCL_OK) {
         2541  +		return(tcl_ret);
         2542  +	}
         2543  +
         2544  +	tv.tv_sec = tv_sec_val;
         2545  +	tv.tv_usec = tv_usec_val; 
         2546  +
         2547  +	adjtime_ret = adjtime(&tv, &oldTV);
         2548  +
         2549  +	if (adjtime_ret != 0) {
         2550  +		Tcl_SetObjResult(interp, Tcl_NewStringObj(strerror(errno), -1));
         2551  +
         2552  +		return(TCL_ERROR);
         2553  +	}
         2554  +
         2555  +	/* XXX TODO: Return old adjustment */
         2556  +
         2557  +	return(TCL_OK);
         2558  +}
         2559  +
  2521   2560   
  2522   2561   #ifndef DISABLE_UNIX_SOCKETS
  2523   2562   struct tuapi_socket_unix__chan_id {
  2524   2563   	int fd;
  2525   2564   	Tcl_Channel chan;
  2526   2565   };
  2527   2566   
................................................................................
  3249   3288   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::insmod", tuapi_insmod, NULL, NULL);
  3250   3289   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::rmmod", tuapi_rmmod, NULL, NULL);
  3251   3290   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::lsmod", tuapi_lsmod, NULL, NULL);
  3252   3291   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::hostname", tuapi_hostname, NULL, NULL);
  3253   3292   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::domainname", tuapi_domainname, NULL, NULL);
  3254   3293   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::klogctl", tuapi_klogctl, NULL, NULL);
  3255   3294   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::settimeofday", tuapi_settimeofday, NULL, NULL);
         3295  +	Tcl_CreateObjCommand(interp, "::tuapi::syscall::adjtime", tuapi_adjtime, NULL, NULL);
  3256   3296   
  3257   3297   	/* Block or char device related commands */
  3258   3298   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::losetup", tuapi_losetup, NULL, NULL);
  3259   3299   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::eject", tuapi_eject, NULL, NULL);
  3260   3300   
  3261   3301   	/* Filesystem related commands */
  3262   3302   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::mount", tuapi_mount, NULL, NULL);