/**
   * Blocks the calling thread until the specified sync object is signaled, or until a specified
   * timeout value expires.
   *
   * @param sync the sync object
   * @param flags the block flags
   * @param timeout the block timeout
   * @return the sync object status
   * @throws org.lwjgl.LWJGLException if an EGL error occurs.
   */
  public static int eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, int flags, long timeout)
      throws LWJGLException {
    final int status = neglClientWaitSyncKHR(dpy.getPointer(), sync.getPointer(), flags, timeout);

    if (status == EGL_FALSE) throwEGLError("Failed to block on KHR fence sync object.");

    return status;
  }
  /**
   * Returns the value of the sync object attribute.
   *
   * @param sync the sync object
   * @param attribute the attribute to query
   * @return the attribute value
   * @throws org.lwjgl.LWJGLException if an EGL error occurs.
   */
  public static int eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, int attribute)
      throws LWJGLException {
    final IntBuffer value = APIUtil.getBufferInt();

    if (!neglGetSyncAttribKHR(
        dpy.getPointer(), sync.getPointer(), attribute, MemoryUtil.getAddress(value)))
      throwEGLError("Failed to get KHR fence sync object attribute.");

    return value.get(0);
  }
  /**
   * Creates a fence sync object for the specified EGL display and returns a handle to the new
   * object.
   *
   * @param dpy the EGL display
   * @param type the sync type
   * @param attrib_list an attribute list (may be null)
   * @return the created fence sync object
   * @throws org.lwjgl.LWJGLException if an EGL error occurs.
   */
  public static EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, int type, IntBuffer attrib_list)
      throws LWJGLException {
    checkAttribList(attrib_list);

    final long pointer =
        neglCreateSyncKHR(dpy.getPointer(), type, MemoryUtil.getAddressSafe(attrib_list));

    if (pointer == EGL_NO_SYNC_KHR) throwEGLError("Failed to create KHR fence sync object.");

    return new EGLSyncKHR(pointer);
  }
 /**
  * Destroys an existing sync object.
  *
  * @param sync the sync object
  * @throws org.lwjgl.LWJGLException if an EGL error occurs.
  */
 public static void eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync) throws LWJGLException {
   if (!neglDestroySyncKHR(dpy.getPointer(), sync.getPointer()))
     throwEGLError("Failed to destroy KHR fence sync object.");
 }