Changeset bd41ac52 in mainline for uspace/app/tetris


Ignore:
Timestamp:
2018-08-25T22:21:25Z (7 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.

Location:
uspace/app/tetris
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tetris/scores.h

    re2625b1a rbd41ac52  
    5454 */
    5555
    56 #include <sys/time.h>
     56#include <time.h>
    5757#include <str.h>
    5858
  • uspace/app/tetris/screen.c

    re2625b1a rbd41ac52  
    7575static const struct shape *lastshape;
    7676
    77 static suseconds_t timeleft = 0;
     77static usec_t timeleft = 0;
    7878
    7979console_ctrl_t *console;
     
    340340void tsleep(void)
    341341{
    342         suseconds_t timeout = fallrate;
     342        usec_t timeout = fallrate;
    343343
    344344        while (timeout > 0) {
  • uspace/app/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 <errno.h>
    5959#include <stdbool.h>
     
    170170static void srandomdev(void)
    171171{
    172         struct timeval tv;
    173 
    174         gettimeofday(&tv, NULL);
    175         srand(tv.tv_sec + tv.tv_usec / 100000);
     172        struct timespec ts;
     173
     174        getrealtime(&ts);
     175        srand(ts.tv_sec + ts.tv_nsec / 100000000);
    176176}
    177177
Note: See TracChangeset for help on using the changeset viewer.