hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

platform_lock.ha (298B)


      1 // License: MPL-2.0
      2 use errors;
      3 use rt;
      4 
      5 fn platform_lock(fd: file, flags: int) (bool | error) = {
      6 	match (rt::flock(fd: int, flags)) {
      7 	case void => return true;
      8 	case let e: rt::errno =>
      9 		if (e == rt::EWOULDBLOCK: rt::errno) {
     10 			return false;
     11 		} else {
     12 			return errors::errno(e);
     13 		};
     14 	};
     15 };