Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • K kernel
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 13
    • Issues 13
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 2
    • Merge requests 2
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • erlends-os
  • kernel
  • kernel
  • Wiki
    • Abi
  • gettimeofday

Last edited by Erlend Sveen Oct 06, 2019
Page history

gettimeofday

Get the current wall clock time. See remarks below.

Syntax

#include <sys/time.h>

int gettimeofday (struct timeval *restrict tp, void *restrict tzp);

Parameters

  • tp

    The structure that will receive the current time.

  • tzp

    Optional argument specifying the timezone. This argument is currently ignored.

Return Value

The return value is null if successful. Otherwise, the return value is negative and errno is set:

  • EINVAL

    The tp argument is not valid.

Remarks

Since most microcontrollers do not contain a real-time (wall time) clock, this system call returns the current system timer counting since the system was booted. In order to get the correct wall time, compensate with a real-time clock.

The time resulution is decided by the system tick timer, which operates at 1 KHz (1 millisecond resolution).

The internal counter is an unsigned 32-bit value, be wary of overflow.

Clone repository
  • abi
    • bind
    • chdir
    • close
    • closedir
    • dup2
    • exit
    • fstat
    • getcwd
    • getpgrp
    • getpid
    • gettimeofday
    • ioctl_fcntl
    • kill
    • link
    • lseek
View All Pages