i have to find time in nanosecond of a particular process and for that i am using clock_gettime() function.

i tried different codes i got from net but getting same error

error: ‘CLOCK_PROCESS_CPUTIME_ID’ undeclared (first use in this function)

i have included relavent header file of time also. and complied the whole code that i got from net. that was working fine and giving output.

but when i use some of the relavent code that i need it gives me this error.
plz tell me am i missing something aur using the code in a wrong way?

heres my code!

#include <stdlib.h>
#include <sys/sysinfo.h> 
#include <openssl/aes.h>
#include <openssl/crypto.h>
#include <sys/time.h>
#include <stdio.h>
#include <unistd.h>

struct sysinfo sys_info;
int days, hours, mins;
char send_data[1024];
////code for aes
   char *key1="mykey01234567891";
   char outs[120];
   char decr[120];
   AES_KEY fkey1[16];
   AES_KEY fkey2[16];
int main () {
    // reset the clock
   struct timespec tS;
    tS.tv_sec = 0;
    tS.tv_nsec = 0;

if(sysinfo(&sys_info) != 0)
		  // Uptime
		  days = sys_info.uptime / 86400;
		  hours = (sys_info.uptime / 3600) - (days * 24);
		  mins = (sys_info.uptime / 60) - (days * 1440) - (hours * 60);
		  printf("Uptime: %ddays, %dhours, %dminutes, %ldseconds\n",
		                      days, hours, mins, sys_info.uptime % 60);
		sprintf(send_data,"%ddays,%dhours,%dmins", days,hours,mins);
	 clock_settime(CLOCK_PROCESS_CPUTIME_ID, &tS);
     //code to encrypt the messege using AES
		AES_set_encrypt_key(key1, 128, fkey1);
  		 AES_encrypt(send_data, outs, fkey1);
	   clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tS);
	printf("Time taken is: %d and %ld ",tS.tv_sec, tS.tv_nsec);
    return 0;

What operating system are you running on?
What version of libraries are you using?

i am using Linux (Fedora) OS and verison of libraries is

It start working now.. i just Replaced the #include <sys/time.h> with just #include <time.h>

but nwo the problem is that its giving me different time (nanoseconds) each time i run the same code.... but i guess it should give same time. because we r finding execution time of a process ( particular function that is AES_set_encrypt_key(key1, 128, fkey1); AES_encrypt(send_data, outs, fkey1); )

so each time it runs it must be taking same time to execute.. then y giving different answer??

How different a time does it give? Have you accounted for the inherent error that is always present whenever you try to take some sort of measurement.