Ignore:
Timestamp:
2018-08-25T22:21:25Z (6 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
cca80a2
Parents:
e2625b1a
Message:

Get rid of sys/time.h

This commit moves the POSIX-like time functionality from libc's
sys/time.h to libposix and introduces C11-like or HelenOS-specific
interfaces to libc.

Specifically, use of sys/time.h, struct timeval, suseconds_t and
gettimeofday is replaced by time.h (C11), struct timespec (C11), usec_t
(HelenOS) and getuptime / getrealtime (HelenOS).

Also attempt to fix the implementation of clock() to return microseconds
(clocks) rather than processor cycles and move it to libc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/dist/src/c/demos/tetris/tetris.c

    re2625b1a rbd41ac52  
    5555    "\tThe Regents of the University of California.  All rights reserved.\n";
    5656
    57 #include <sys/time.h>
     57#include <time.h>
    5858#include <err.h>
    5959#include <errno.h>
     
    171171static void srandomdev(void)
    172172{
    173         struct timeval tv;
    174 
    175         gettimeofday(&tv, NULL);
    176         srand(tv.tv_sec + tv.tv_usec / 100000);
     173        struct timespec ts;
     174
     175        getuptime(&ts);
     176        srand(tv.tv_sec + tv.tv_nsec / 100000000);
    177177}
    178178
Note: See TracChangeset for help on using the changeset viewer.