atomicInc() in C

Hello, I want to transform the CUDA atomicInc() function into C. I have already written this bit of code:

int atomicInc(unsigned int* address, unsigned int val) {

	if(*address >= val)

	return *address;

I don’t know if this code is a right approach.

if ( *address >= val ) 
  // if another thread intercepts here, *address may not be correct value(data-race happen).
  // so comparison and change should be done 'atomic'. use atomicCAS
  *address = 0;