)]}'
{
  "commit": "bcd0b235bf3808dec5115c381cd55568f63b85f0",
  "tree": "d73c4aa83dcd5321d2c48e070020576098b9705e",
  "parents": [
    "4f0989dbfa8d18dd17c32120aac1eb3e906a62a2"
  ],
  "author": {
    "name": "Davide Libenzi",
    "email": "davidel@xmailserver.org",
    "time": "Tue Mar 31 15:24:18 2009 -0700"
  },
  "committer": {
    "name": "Linus Torvalds",
    "email": "torvalds@linux-foundation.org",
    "time": "Wed Apr 01 08:59:20 2009 -0700"
  },
  "message": "eventfd: improve support for semaphore-like behavior\n\nPeople started using eventfd in a semaphore-like way where before they\nwere using pipes.\n\nThat is, counter-based resource access.  Where a \"wait()\" returns\nimmediately by decrementing the counter by one, if counter is greater than\nzero.  Otherwise will wait.  And where a \"post(count)\" will add count to\nthe counter releasing the appropriate amount of waiters.  If eventfd the\n\"post\" (write) part is fine, while the \"wait\" (read) does not dequeue 1,\nbut the whole counter value.\n\nThe problem with eventfd is that a read() on the fd returns and wipes the\nwhole counter, making the use of it as semaphore a little bit more\ncumbersome.  You can do a read() followed by a write() of COUNTER-1, but\nIMO it\u0027s pretty easy and cheap to make this work w/out extra steps.  This\npatch introduces a new eventfd flag that tells eventfd to only dequeue 1\nfrom the counter, allowing simple read/write to make it behave like a\nsemaphore.  Simple test here:\n\nhttp://www.xmailserver.org/eventfd-sem.c\n\nTo be back-compatible with earlier kernels, userspace applications should\nprobe for the availability of this feature via\n\n#ifdef EFD_SEMAPHORE\n\tfd \u003d eventfd2 (CNT, EFD_SEMAPHORE);\n\tif (fd \u003d\u003d -1 \u0026\u0026 errno \u003d\u003d EINVAL)\n\t\t\u003cfallback\u003e\n#else\n\t\t\u003cfallback\u003e\n#endif\n\nSigned-off-by: Davide Libenzi \u003cdavidel@xmailserver.org\u003e\nCc: \u003clinux-api@vger.kernel.org\u003e\nTested-by: Michael Kerrisk \u003cmtk.manpages@gmail.com\u003e\nCc: Ulrich Drepper \u003cdrepper@redhat.com\u003e\nSigned-off-by: Andrew Morton \u003cakpm@linux-foundation.org\u003e\nSigned-off-by: Linus Torvalds \u003ctorvalds@linux-foundation.org\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "5de2c2db3aa2381ccc04b02ca440ba56d14cfaba",
      "old_mode": 33188,
      "old_path": "fs/eventfd.c",
      "new_id": "91c0829a703578f9145778fc914e53e6ad71e3f7",
      "new_mode": 33188,
      "new_path": "fs/eventfd.c"
    },
    {
      "type": "modify",
      "old_id": "a667637b54e3912783c9f1e086c57df74784e05b",
      "old_mode": 33188,
      "old_path": "include/linux/eventfd.h",
      "new_id": "f45a8ae5f8281bc51348b942a36899b8355f13d9",
      "new_mode": 33188,
      "new_path": "include/linux/eventfd.h"
    }
  ]
}
