Generated bridge.h

Generated bridge.h

--- jni/bridge.h
+++ jni/bridge.h
@@ -1,123 +1,736 @@
-#ifndef _GO_JNI_BRIDGE_H_
-#define _GO_JNI_BRIDGE_H_
+#ifndef _GO_JNI_JNIENV_H_
+#define _GO_JNI_JNIENV_H_

 #include <jni.h>

 // jni.h:
 //     jint (JNICALL *GetVersion)(JNIEnv *env);
-jint _GoJniGetVersion(JNIEnv *env);
+jint _GoJniGetVersion(JNIEnv* env);

 // jni.h:
 //     jclass (JNICALL *DefineClass)(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len);
-jclass _GoJniDefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len);
+jclass _GoJniDefineClass(JNIEnv* env, const char* name, jobject loader, const jbyte* buf, jsize len);

 // jni.h:
 //     jclass (JNICALL *FindClass)(JNIEnv *env, const char *name);
-jclass _GoJniFindClass(JNIEnv *env, const char *name);
+jclass _GoJniFindClass(JNIEnv* env, const char* name);

 // jni.h:
 //     jmethodID (JNICALL *FromReflectedMethod)(JNIEnv *env, jobject method);
-jmethodID _GoJniFromReflectedMethod(JNIEnv *env, jobject method);
+jmethodID _GoJniFromReflectedMethod(JNIEnv* env, jobject method);

 // jni.h:
 //     jfieldID (JNICALL *FromReflectedField)(JNIEnv *env, jobject field);
-jfieldID _GoJniFromReflectedField(JNIEnv *env, jobject field);
+jfieldID _GoJniFromReflectedField(JNIEnv* env, jobject field);

 // jni.h:
 //     jobject (JNICALL *ToReflectedMethod)(JNIEnv *env, jclass cls, jmethodID methodID, jboolean isStatic);
-jobject _GoJniToReflectedMethod(JNIEnv *env, jclass cls, jmethodID methodID, jboolean isStatic);
+jobject _GoJniToReflectedMethod(JNIEnv* env, jclass cls, jmethodID methodID, jboolean isStatic);

 // jni.h:
 //     jclass (JNICALL *GetSuperclass)(JNIEnv *env, jclass sub);
-jclass _GoJniGetSuperclass(JNIEnv *env, jclass sub);
+jclass _GoJniGetSuperclass(JNIEnv* env, jclass sub);

 // jni.h:
 //     jboolean (JNICALL *IsAssignableFrom)(JNIEnv *env, jclass sub, jclass sup);
-jboolean _GoJniIsAssignableFrom(JNIEnv *env, jclass sub, jclass sup);
+jboolean _GoJniIsAssignableFrom(JNIEnv* env, jclass sub, jclass sup);

 // jni.h:
 //     jobject (JNICALL *ToReflectedField)(JNIEnv *env, jclass cls, jfieldID fieldID, jboolean isStatic);
-jobject _GoJniToReflectedField(JNIEnv *env, jclass cls, jfieldID fieldID, jboolean isStatic);
+jobject _GoJniToReflectedField(JNIEnv* env, jclass cls, jfieldID fieldID, jboolean isStatic);

 // jni.h:
 //     jint (JNICALL *Throw)(JNIEnv *env, jthrowable obj);
-jint _GoJniThrow(JNIEnv *env, jthrowable obj);
+jint _GoJniThrow(JNIEnv* env, jthrowable obj);

 // jni.h:
 //     jint (JNICALL *ThrowNew)(JNIEnv *env, jclass clazz, const char *msg);
-jint _GoJniThrowNew(JNIEnv *env, jclass clazz, const char *msg);
+jint _GoJniThrowNew(JNIEnv* env, jclass clazz, const char* msg);

 // jni.h:
 //     jthrowable (JNICALL *ExceptionOccurred)(JNIEnv *env);
-jthrowable _GoJniExceptionOccurred(JNIEnv *env);
+jthrowable _GoJniExceptionOccurred(JNIEnv* env);

 // jni.h:
 //     void (JNICALL *ExceptionDescribe)(JNIEnv *env);
-void _GoJniExceptionDescribe(JNIEnv *env);
+void _GoJniExceptionDescribe(JNIEnv* env);

 // jni.h:
 //     void (JNICALL *ExceptionClear)(JNIEnv *env);
-void _GoJniExceptionClear(JNIEnv *env);
+void _GoJniExceptionClear(JNIEnv* env);

 // jni.h:
 //     void (JNICALL *FatalError)(JNIEnv *env, const char *msg);
-void _GoJniFatalError(JNIEnv *env, const char *msg);
+void _GoJniFatalError(JNIEnv* env, const char* msg);

 // jni.h:
 //     jint (JNICALL *PushLocalFrame)(JNIEnv *env, jint capacity);
-jint _GoJniPushLocalFrame(JNIEnv *env, jint capacity);
+jint _GoJniPushLocalFrame(JNIEnv* env, jint capacity);

 // jni.h:
 //     jobject (JNICALL *PopLocalFrame)(JNIEnv *env, jobject result);
-jobject _GoJniPopLocalFrame(JNIEnv *env, jobject result);
+jobject _GoJniPopLocalFrame(JNIEnv* env, jobject result);

 // jni.h:
 //     jobject (JNICALL *NewGlobalRef)(JNIEnv *env, jobject lobj);
-jobject _GoJniNewGlobalRef(JNIEnv *env, jobject lobj);
+jobject _GoJniNewGlobalRef(JNIEnv* env, jobject lobj);

 // jni.h:
 //     void (JNICALL *DeleteGlobalRef)(JNIEnv *env, jobject gref);
-void _GoJniDeleteGlobalRef(JNIEnv *env, jobject gref);
+void _GoJniDeleteGlobalRef(JNIEnv* env, jobject gref);

 // jni.h:
 //     void (JNICALL *DeleteLocalRef)(JNIEnv *env, jobject obj);
-void _GoJniDeleteLocalRef(JNIEnv *env, jobject obj);
+void _GoJniDeleteLocalRef(JNIEnv* env, jobject obj);

 // jni.h:
 //     jboolean (JNICALL *IsSameObject)(JNIEnv *env, jobject obj1, jobject obj2);
-jboolean _GoJniIsSameObject(JNIEnv *env, jobject obj1, jobject obj2);
+jboolean _GoJniIsSameObject(JNIEnv* env, jobject obj1, jobject obj2);

 // jni.h:
 //     jobject (JNICALL *NewLocalRef)(JNIEnv *env, jobject ref);
-jobject _GoJniNewLocalRef(JNIEnv *env, jobject ref);
+jobject _GoJniNewLocalRef(JNIEnv* env, jobject ref);

 // jni.h:
 //     jint (JNICALL *EnsureLocalCapacity)(JNIEnv *env, jint capacity);
-jint _GoJniEnsureLocalCapacity(JNIEnv *env, jint capacity);
+jint _GoJniEnsureLocalCapacity(JNIEnv* env, jint capacity);

 // jni.h:
 //     jobject (JNICALL *AllocObject)(JNIEnv *env, jclass clazz);
-jobject _GoJniAllocObject(JNIEnv *env, jclass clazz);
+jobject _GoJniAllocObject(JNIEnv* env, jclass clazz);

 // jni.h:
 //     jobject (JNICALL *NewObject)(JNIEnv *env, jclass clazz, jmethodID methodID, ...);
 //     jobject (JNICALL *NewObjectV)(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
 //     jobject (JNICALL *NewObjectA)(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
-jobject _GoJniNewObjectA(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
+jobject _GoJniNewObjectA(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args);

 // jni.h:
 //     jclass (JNICALL *GetObjectClass)(JNIEnv *env, jobject obj);
-jclass _GoJniGetObjectClass(JNIEnv *env, jobject obj);
+jclass _GoJniGetObjectClass(JNIEnv* env, jobject obj);

 // jni.h:
 //     jboolean (JNICALL *IsInstanceOf)(JNIEnv *env, jobject obj, jclass clazz);
-jboolean _GoJniIsInstanceOf(JNIEnv *env, jobject obj, jclass clazz);
-
-
-
-
-jmethodID _GoJniGetStaticMethodID(JNIEnv *env, jclass class, const char *name, const char *sig);
-
-void _GoJniCallStaticVoidMethod(JNIEnv *env, jclass clazz, jmethodID methodID);
-
-#endif // #ifndef _GO_JNI_BRIDGE_H_
+jboolean _GoJniIsInstanceOf(JNIEnv* env, jobject obj, jclass clazz);
+
+// jni.h:
+//     jmethodID (JNICALL *GetMethodID)(JNIEnv *env, jclass clazz, const char *name, const char *sig);
+jmethodID _GoJniGetMethodID(JNIEnv* env, jclass clazz, const char* name, const char* sig);
+
+// jni.h:
+//     jobject (JNICALL *CallObjectMethod)(JNIEnv *env, jobject obj, jmethodID methodID, ...);
+//     jobject (JNICALL *CallObjectMethodV)(JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
+//     jobject (JNICALL *CallObjectMethodA)(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue * args);
+jobject _GoJniCallObjectMethodA(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jboolean (JNICALL *CallBooleanMethod)(JNIEnv *env, jobject obj, jmethodID methodID, ...);
+//     jboolean (JNICALL *CallBooleanMethodV)(JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
+//     jboolean (JNICALL *CallBooleanMethodA)(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue * args);
+jboolean _GoJniCallBooleanMethodA(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jbyte (JNICALL *CallByteMethod)(JNIEnv *env, jobject obj, jmethodID methodID, ...);
+//     jbyte (JNICALL *CallByteMethodV)(JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
+//     jbyte (JNICALL *CallByteMethodA)(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);
+jbyte _GoJniCallByteMethodA(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jchar (JNICALL *CallCharMethod)(JNIEnv *env, jobject obj, jmethodID methodID, ...);
+//     jchar (JNICALL *CallCharMethodV)(JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
+//     jchar (JNICALL *CallCharMethodA)(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);
+jchar _GoJniCallCharMethodA(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jshort (JNICALL *CallShortMethod)(JNIEnv *env, jobject obj, jmethodID methodID, ...);
+//     jshort (JNICALL *CallShortMethodV)(JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
+//     jshort (JNICALL *CallShortMethodA)(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);
+jshort _GoJniCallShortMethodA(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jint (JNICALL *CallIntMethod)(JNIEnv *env, jobject obj, jmethodID methodID, ...);
+//     jint (JNICALL *CallIntMethodV)(JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
+//     jint (JNICALL *CallIntMethodA)(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);
+jint _GoJniCallIntMethodA(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jlong (JNICALL *CallLongMethod)(JNIEnv *env, jobject obj, jmethodID methodID, ...);
+//     jlong (JNICALL *CallLongMethodV)(JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
+//     jlong (JNICALL *CallLongMethodA)(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);
+jlong _GoJniCallLongMethodA(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jfloat (JNICALL *CallFloatMethod)(JNIEnv *env, jobject obj, jmethodID methodID, ...);
+//     jfloat (JNICALL *CallFloatMethodV)(JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
+//     jfloat (JNICALL *CallFloatMethodA)(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);
+jfloat _GoJniCallFloatMethodA(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jdouble (JNICALL *CallDoubleMethod)(JNIEnv *env, jobject obj, jmethodID methodID, ...);
+//     jdouble (JNICALL *CallDoubleMethodV)(JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
+//     jdouble (JNICALL *CallDoubleMethodA)(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args);
+jdouble _GoJniCallDoubleMethodA(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     void (JNICALL *CallVoidMethod)(JNIEnv *env, jobject obj, jmethodID methodID, ...);
+//     void (JNICALL *CallVoidMethodV)(JNIEnv *env, jobject obj, jmethodID methodID, va_list args);
+//     void (JNICALL *CallVoidMethodA)(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue * args);
+void _GoJniCallVoidMethodA(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jobject (JNICALL *CallNonvirtualObjectMethod)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
+//     jobject (JNICALL *CallNonvirtualObjectMethodV)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+//     jobject (JNICALL *CallNonvirtualObjectMethodA)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, const jvalue * args);
+jobject _GoJniCallNonvirtualObjectMethodA(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jboolean (JNICALL *CallNonvirtualBooleanMethod)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
+//     jboolean (JNICALL *CallNonvirtualBooleanMethodV)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+//     jboolean (JNICALL *CallNonvirtualBooleanMethodA)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, const jvalue * args);
+jboolean _GoJniCallNonvirtualBooleanMethodA(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jbyte (JNICALL *CallNonvirtualByteMethod)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
+//     jbyte (JNICALL *CallNonvirtualByteMethodV)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+//     jbyte (JNICALL *CallNonvirtualByteMethodA)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, const jvalue *args);
+jbyte _GoJniCallNonvirtualByteMethodA(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jchar (JNICALL *CallNonvirtualCharMethod)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
+//     jchar (JNICALL *CallNonvirtualCharMethodV)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+//     jchar (JNICALL *CallNonvirtualCharMethodA)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, const jvalue *args);
+jchar _GoJniCallNonvirtualCharMethodA(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jshort (JNICALL *CallNonvirtualShortMethod)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
+//     jshort (JNICALL *CallNonvirtualShortMethodV)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+//     jshort (JNICALL *CallNonvirtualShortMethodA)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, const jvalue *args);
+jshort _GoJniCallNonvirtualShortMethodA(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jint (JNICALL *CallNonvirtualIntMethod)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
+//     jint (JNICALL *CallNonvirtualIntMethodV)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+//     jint (JNICALL *CallNonvirtualIntMethodA)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, const jvalue *args);
+jint _GoJniCallNonvirtualIntMethodA(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jlong (JNICALL *CallNonvirtualLongMethod)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
+//     jlong (JNICALL *CallNonvirtualLongMethodV)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+//     jlong (JNICALL *CallNonvirtualLongMethodA)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, const jvalue *args);
+jlong _GoJniCallNonvirtualLongMethodA(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jfloat (JNICALL *CallNonvirtualFloatMethod)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
+//     jfloat (JNICALL *CallNonvirtualFloatMethodV)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+//     jfloat (JNICALL *CallNonvirtualFloatMethodA)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, const jvalue *args);
+jfloat _GoJniCallNonvirtualFloatMethodA(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jdouble (JNICALL *CallNonvirtualDoubleMethod)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
+//     jdouble (JNICALL *CallNonvirtualDoubleMethodV)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+//     jdouble (JNICALL *CallNonvirtualDoubleMethodA)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, const jvalue *args);
+jdouble _GoJniCallNonvirtualDoubleMethodA(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     void (JNICALL *CallNonvirtualVoidMethod)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...);
+//     void (JNICALL *CallNonvirtualVoidMethodV)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args);
+//     void (JNICALL *CallNonvirtualVoidMethodA)(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, const jvalue * args);
+void _GoJniCallNonvirtualVoidMethodA(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jfieldID (JNICALL *GetFieldID)(JNIEnv *env, jclass clazz, const char *name, const char *sig);
+jfieldID _GoJniGetFieldID(JNIEnv* env, jclass clazz, const char* name, const char* sig);
+
+// jni.h:
+//     jobject (JNICALL *GetObjectField)(JNIEnv *env, jobject obj, jfieldID fieldID);
+jobject _GoJniGetObjectField(JNIEnv* env, jobject obj, jfieldID fieldID);
+
+// jni.h:
+//     jboolean (JNICALL *GetBooleanField)(JNIEnv *env, jobject obj, jfieldID fieldID);
+jboolean _GoJniGetBooleanField(JNIEnv* env, jobject obj, jfieldID fieldID);
+
+// jni.h:
+//     jbyte (JNICALL *GetByteField)(JNIEnv *env, jobject obj, jfieldID fieldID);
+jbyte _GoJniGetByteField(JNIEnv* env, jobject obj, jfieldID fieldID);
+
+// jni.h:
+//     jchar (JNICALL *GetCharField)(JNIEnv *env, jobject obj, jfieldID fieldID);
+jchar _GoJniGetCharField(JNIEnv* env, jobject obj, jfieldID fieldID);
+
+// jni.h:
+//     jshort (JNICALL *GetShortField)(JNIEnv *env, jobject obj, jfieldID fieldID);
+jshort _GoJniGetShortField(JNIEnv* env, jobject obj, jfieldID fieldID);
+
+// jni.h:
+//     jint (JNICALL *GetIntField)(JNIEnv *env, jobject obj, jfieldID fieldID);
+jint _GoJniGetIntField(JNIEnv* env, jobject obj, jfieldID fieldID);
+
+// jni.h:
+//     jlong (JNICALL *GetLongField)(JNIEnv *env, jobject obj, jfieldID fieldID);
+jlong _GoJniGetLongField(JNIEnv* env, jobject obj, jfieldID fieldID);
+
+// jni.h:
+//     jfloat (JNICALL *GetFloatField)(JNIEnv *env, jobject obj, jfieldID fieldID);
+jfloat _GoJniGetFloatField(JNIEnv* env, jobject obj, jfieldID fieldID);
+
+// jni.h:
+//     jdouble (JNICALL *GetDoubleField)(JNIEnv *env, jobject obj, jfieldID fieldID);
+jdouble _GoJniGetDoubleField(JNIEnv* env, jobject obj, jfieldID fieldID);
+
+// jni.h:
+//     void (JNICALL *SetObjectField)(JNIEnv *env, jobject obj, jfieldID fieldID, jobject val);
+void _GoJniSetObjectField(JNIEnv* env, jobject obj, jfieldID fieldID, jobject val);
+
+// jni.h:
+//     void (JNICALL *SetBooleanField)(JNIEnv *env, jobject obj, jfieldID fieldID, jboolean val);
+void _GoJniSetBooleanField(JNIEnv* env, jobject obj, jfieldID fieldID, jboolean val);
+
+// jni.h:
+//     void (JNICALL *SetByteField)(JNIEnv *env, jobject obj, jfieldID fieldID, jbyte val);
+void _GoJniSetByteField(JNIEnv* env, jobject obj, jfieldID fieldID, jbyte val);
+
+// jni.h:
+//     void (JNICALL *SetCharField)(JNIEnv *env, jobject obj, jfieldID fieldID, jchar val);
+void _GoJniSetCharField(JNIEnv* env, jobject obj, jfieldID fieldID, jchar val);
+
+// jni.h:
+//     void (JNICALL *SetShortField)(JNIEnv *env, jobject obj, jfieldID fieldID, jshort val);
+void _GoJniSetShortField(JNIEnv* env, jobject obj, jfieldID fieldID, jshort val);
+
+// jni.h:
+//     void (JNICALL *SetIntField)(JNIEnv *env, jobject obj, jfieldID fieldID, jint val);
+void _GoJniSetIntField(JNIEnv* env, jobject obj, jfieldID fieldID, jint val);
+
+// jni.h:
+//     void (JNICALL *SetLongField)(JNIEnv *env, jobject obj, jfieldID fieldID, jlong val);
+void _GoJniSetLongField(JNIEnv* env, jobject obj, jfieldID fieldID, jlong val);
+
+// jni.h:
+//     void (JNICALL *SetFloatField)(JNIEnv *env, jobject obj, jfieldID fieldID, jfloat val);
+void _GoJniSetFloatField(JNIEnv* env, jobject obj, jfieldID fieldID, jfloat val);
+
+// jni.h:
+//     void (JNICALL *SetDoubleField)(JNIEnv *env, jobject obj, jfieldID fieldID, jdouble val);
+void _GoJniSetDoubleField(JNIEnv* env, jobject obj, jfieldID fieldID, jdouble val);
+
+// jni.h:
+//     jmethodID (JNICALL *GetStaticMethodID)(JNIEnv *env, jclass clazz, const char *name, const char *sig);
+jmethodID _GoJniGetStaticMethodID(JNIEnv* env, jclass clazz, const char* name, const char* sig);
+
+// jni.h:
+//     jobject (JNICALL *CallStaticObjectMethod)(JNIEnv *env, jclass clazz, jmethodID methodID, ...);
+//     jobject (JNICALL *CallStaticObjectMethodV)(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
+//     jobject (JNICALL *CallStaticObjectMethodA)(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
+jobject _GoJniCallStaticObjectMethodA(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jboolean (JNICALL *CallStaticBooleanMethod)(JNIEnv *env, jclass clazz, jmethodID methodID, ...);
+//     jboolean (JNICALL *CallStaticBooleanMethodV)(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
+//     jboolean (JNICALL *CallStaticBooleanMethodA)(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
+jboolean _GoJniCallStaticBooleanMethodA(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jbyte (JNICALL *CallStaticByteMethod)(JNIEnv *env, jclass clazz, jmethodID methodID, ...);
+//     jbyte (JNICALL *CallStaticByteMethodV)(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
+//     jbyte (JNICALL *CallStaticByteMethodA)(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
+jbyte _GoJniCallStaticByteMethodA(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jchar (JNICALL *CallStaticCharMethod)(JNIEnv *env, jclass clazz, jmethodID methodID, ...);
+//     jchar (JNICALL *CallStaticCharMethodV)(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
+//     jchar (JNICALL *CallStaticCharMethodA)(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
+jchar _GoJniCallStaticCharMethodA(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jshort (JNICALL *CallStaticShortMethod)(JNIEnv *env, jclass clazz, jmethodID methodID, ...);
+//     jshort (JNICALL *CallStaticShortMethodV)(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
+//     jshort (JNICALL *CallStaticShortMethodA)(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
+jshort _GoJniCallStaticShortMethodA(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jint (JNICALL *CallStaticIntMethod)(JNIEnv *env, jclass clazz, jmethodID methodID, ...);
+//     jint (JNICALL *CallStaticIntMethodV)(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
+//     jint (JNICALL *CallStaticIntMethodA)(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
+jint _GoJniCallStaticIntMethodA(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jlong (JNICALL *CallStaticLongMethod)(JNIEnv *env, jclass clazz, jmethodID methodID, ...);
+//     jlong (JNICALL *CallStaticLongMethodV)(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
+//     jlong (JNICALL *CallStaticLongMethodA)(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
+jlong _GoJniCallStaticLongMethodA(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jfloat (JNICALL *CallStaticFloatMethod)(JNIEnv *env, jclass clazz, jmethodID methodID, ...);
+//     jfloat (JNICALL *CallStaticFloatMethodV)(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
+//     jfloat (JNICALL *CallStaticFloatMethodA)(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
+jfloat _GoJniCallStaticFloatMethodA(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jdouble (JNICALL *CallStaticDoubleMethod)(JNIEnv *env, jclass clazz, jmethodID methodID, ...);
+//     jdouble (JNICALL *CallStaticDoubleMethodV)(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
+//     jdouble (JNICALL *CallStaticDoubleMethodA)(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args);
+jdouble _GoJniCallStaticDoubleMethodA(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     void (JNICALL *CallStaticVoidMethod)(JNIEnv *env, jclass cls, jmethodID methodID, ...);
+//     void (JNICALL *CallStaticVoidMethodV)(JNIEnv *env, jclass cls, jmethodID methodID, va_list args);
+//     void (JNICALL *CallStaticVoidMethodA)(JNIEnv *env, jclass cls, jmethodID methodID, const jvalue * args);
+void _GoJniCallStaticVoidMethodA(JNIEnv* env, jclass cls, jmethodID methodID, const jvalue* args);
+
+// jni.h:
+//     jfieldID (JNICALL *GetStaticFieldID)(JNIEnv *env, jclass clazz, const char *name, const char *sig);
+jfieldID _GoJniGetStaticFieldID(JNIEnv* env, jclass clazz, const char* name, const char* sig);
+
+// jni.h:
+//     jobject (JNICALL *GetStaticObjectField)(JNIEnv *env, jclass clazz, jfieldID fieldID);
+jobject _GoJniGetStaticObjectField(JNIEnv* env, jclass clazz, jfieldID fieldID);
+
+// jni.h:
+//     jboolean (JNICALL *GetStaticBooleanField)(JNIEnv *env, jclass clazz, jfieldID fieldID);
+jboolean _GoJniGetStaticBooleanField(JNIEnv* env, jclass clazz, jfieldID fieldID);
+
+// jni.h:
+//     jbyte (JNICALL *GetStaticByteField)(JNIEnv *env, jclass clazz, jfieldID fieldID);
+jbyte _GoJniGetStaticByteField(JNIEnv* env, jclass clazz, jfieldID fieldID);
+
+// jni.h:
+//     jchar (JNICALL *GetStaticCharField)(JNIEnv *env, jclass clazz, jfieldID fieldID);
+jchar _GoJniGetStaticCharField(JNIEnv* env, jclass clazz, jfieldID fieldID);
+
+// jni.h:
+//     jshort (JNICALL *GetStaticShortField)(JNIEnv *env, jclass clazz, jfieldID fieldID);
+jshort _GoJniGetStaticShortField(JNIEnv* env, jclass clazz, jfieldID fieldID);
+
+// jni.h:
+//     jint (JNICALL *GetStaticIntField)(JNIEnv *env, jclass clazz, jfieldID fieldID);
+jint _GoJniGetStaticIntField(JNIEnv* env, jclass clazz, jfieldID fieldID);
+
+// jni.h:
+//     jlong (JNICALL *GetStaticLongField)(JNIEnv *env, jclass clazz, jfieldID fieldID);
+jlong _GoJniGetStaticLongField(JNIEnv* env, jclass clazz, jfieldID fieldID);
+
+// jni.h:
+//     jfloat (JNICALL *GetStaticFloatField)(JNIEnv *env, jclass clazz, jfieldID fieldID);
+jfloat _GoJniGetStaticFloatField(JNIEnv* env, jclass clazz, jfieldID fieldID);
+
+// jni.h:
+//     jdouble (JNICALL *GetStaticDoubleField)(JNIEnv *env, jclass clazz, jfieldID fieldID);
+jdouble _GoJniGetStaticDoubleField(JNIEnv* env, jclass clazz, jfieldID fieldID);
+
+// jni.h:
+//     void (JNICALL *SetStaticObjectField)(JNIEnv *env, jclass clazz, jfieldID fieldID, jobject value);
+void _GoJniSetStaticObjectField(JNIEnv* env, jclass clazz, jfieldID fieldID, jobject value);
+
+// jni.h:
+//     void (JNICALL *SetStaticBooleanField)(JNIEnv *env, jclass clazz, jfieldID fieldID, jboolean value);
+void _GoJniSetStaticBooleanField(JNIEnv* env, jclass clazz, jfieldID fieldID, jboolean value);
+
+// jni.h:
+//     void (JNICALL *SetStaticByteField)(JNIEnv *env, jclass clazz, jfieldID fieldID, jbyte value);
+void _GoJniSetStaticByteField(JNIEnv* env, jclass clazz, jfieldID fieldID, jbyte value);
+
+// jni.h:
+//     void (JNICALL *SetStaticCharField)(JNIEnv *env, jclass clazz, jfieldID fieldID, jchar value);
+void _GoJniSetStaticCharField(JNIEnv* env, jclass clazz, jfieldID fieldID, jchar value);
+
+// jni.h:
+//     void (JNICALL *SetStaticShortField)(JNIEnv *env, jclass clazz, jfieldID fieldID, jshort value);
+void _GoJniSetStaticShortField(JNIEnv* env, jclass clazz, jfieldID fieldID, jshort value);
+
+// jni.h:
+//     void (JNICALL *SetStaticIntField)(JNIEnv *env, jclass clazz, jfieldID fieldID, jint value);
+void _GoJniSetStaticIntField(JNIEnv* env, jclass clazz, jfieldID fieldID, jint value);
+
+// jni.h:
+//     void (JNICALL *SetStaticLongField)(JNIEnv *env, jclass clazz, jfieldID fieldID, jlong value);
+void _GoJniSetStaticLongField(JNIEnv* env, jclass clazz, jfieldID fieldID, jlong value);
+
+// jni.h:
+//     void (JNICALL *SetStaticFloatField)(JNIEnv *env, jclass clazz, jfieldID fieldID, jfloat value);
+void _GoJniSetStaticFloatField(JNIEnv* env, jclass clazz, jfieldID fieldID, jfloat value);
+
+// jni.h:
+//     void (JNICALL *SetStaticDoubleField)(JNIEnv *env, jclass clazz, jfieldID fieldID, jdouble value);
+void _GoJniSetStaticDoubleField(JNIEnv* env, jclass clazz, jfieldID fieldID, jdouble value);
+
+// jni.h:
+//     jstring (JNICALL *NewString)(JNIEnv *env, const jchar *unicode, jsize len);
+jstring _GoJniNewString(JNIEnv* env, const jchar* unicode, jsize len);
+
+// jni.h:
+//     jsize (JNICALL *GetStringLength)(JNIEnv *env, jstring str);
+jsize _GoJniGetStringLength(JNIEnv* env, jstring str);
+
+// jni.h:
+//     const jchar *(JNICALL *GetStringChars)(JNIEnv *env, jstring str, jboolean *isCopy);
+const jchar* _GoJniGetStringChars(JNIEnv* env, jstring str, jboolean* isCopy);
+
+// jni.h:
+//     void (JNICALL *ReleaseStringChars)(JNIEnv *env, jstring str, const jchar *chars);
+void _GoJniReleaseStringChars(JNIEnv* env, jstring str, const jchar* chars);
+
+// jni.h:
+//     jstring (JNICALL *NewStringUTF)(JNIEnv *env, const char *utf);
+jstring _GoJniNewStringUTF(JNIEnv* env, const char* utf);
+
+// jni.h:
+//     jsize (JNICALL *GetStringUTFLength)(JNIEnv *env, jstring str);
+jsize _GoJniGetStringUTFLength(JNIEnv* env, jstring str);
+
+// jni.h:
+//     const char* (JNICALL *GetStringUTFChars)(JNIEnv *env, jstring str, jboolean *isCopy);
+const char* _GoJniGetStringUTFChars(JNIEnv* env, jstring str, jboolean* isCopy);
+
+// jni.h:
+//     void (JNICALL *ReleaseStringUTFChars)(JNIEnv *env, jstring str, const char* chars);
+void _GoJniReleaseStringUTFChars(JNIEnv* env, jstring str, const char* chars);
+
+// jni.h:
+//     jsize (JNICALL *GetArrayLength)(JNIEnv *env, jarray array);
+jsize _GoJniGetArrayLength(JNIEnv* env, jarray array);
+
+// jni.h:
+//     jobjectArray (JNICALL *NewObjectArray)(JNIEnv *env, jsize len, jclass clazz, jobject init);
+jobjectArray _GoJniNewObjectArray(JNIEnv* env, jsize len, jclass clazz, jobject init);
+
+// jni.h:
+//     jobject (JNICALL *GetObjectArrayElement)(JNIEnv *env, jobjectArray array, jsize index);
+jobject _GoJniGetObjectArrayElement(JNIEnv* env, jobjectArray array, jsize index);
+
+// jni.h:
+//     void (JNICALL *SetObjectArrayElement)(JNIEnv *env, jobjectArray array, jsize index, jobject val);
+void _GoJniSetObjectArrayElement(JNIEnv* env, jobjectArray array, jsize index, jobject val);
+
+// jni.h:
+//     jbooleanArray (JNICALL *NewBooleanArray)(JNIEnv *env, jsize len);
+jbooleanArray _GoJniNewBooleanArray(JNIEnv* env, jsize len);
+
+// jni.h:
+//     jbyteArray (JNICALL *NewByteArray)(JNIEnv *env, jsize len);
+jbyteArray _GoJniNewByteArray(JNIEnv* env, jsize len);
+
+// jni.h:
+//     jcharArray (JNICALL *NewCharArray)(JNIEnv *env, jsize len);
+jcharArray _GoJniNewCharArray(JNIEnv* env, jsize len);
+
+// jni.h:
+//     jshortArray (JNICALL *NewShortArray)(JNIEnv *env, jsize len);
+jshortArray _GoJniNewShortArray(JNIEnv* env, jsize len);
+
+// jni.h:
+//     jintArray (JNICALL *NewIntArray)(JNIEnv *env, jsize len);
+jintArray _GoJniNewIntArray(JNIEnv* env, jsize len);
+
+// jni.h:
+//     jlongArray (JNICALL *NewLongArray)(JNIEnv *env, jsize len);
+jlongArray _GoJniNewLongArray(JNIEnv* env, jsize len);
+
+// jni.h:
+//     jfloatArray (JNICALL *NewFloatArray)(JNIEnv *env, jsize len);
+jfloatArray _GoJniNewFloatArray(JNIEnv* env, jsize len);
+
+// jni.h:
+//     jdoubleArray (JNICALL *NewDoubleArray)(JNIEnv *env, jsize len);
+jdoubleArray _GoJniNewDoubleArray(JNIEnv* env, jsize len);
+
+// jni.h:
+//     jboolean * (JNICALL *GetBooleanArrayElements)(JNIEnv *env, jbooleanArray array, jboolean *isCopy);
+jboolean* _GoJniGetBooleanArrayElements(JNIEnv* env, jbooleanArray array, jboolean* isCopy);
+
+// jni.h:
+//     jbyte * (JNICALL *GetByteArrayElements)(JNIEnv *env, jbyteArray array, jboolean *isCopy);
+jbyte* _GoJniGetByteArrayElements(JNIEnv* env, jbyteArray array, jboolean* isCopy);
+
+// jni.h:
+//     jchar * (JNICALL *GetCharArrayElements)(JNIEnv *env, jcharArray array, jboolean *isCopy);
+jchar* _GoJniGetCharArrayElements(JNIEnv* env, jcharArray array, jboolean* isCopy);
+
+// jni.h:
+//     jshort * (JNICALL *GetShortArrayElements)(JNIEnv *env, jshortArray array, jboolean *isCopy);
+jshort* _GoJniGetShortArrayElements(JNIEnv* env, jshortArray array, jboolean* isCopy);
+
+// jni.h:
+//     jint * (JNICALL *GetIntArrayElements)(JNIEnv *env, jintArray array, jboolean *isCopy);
+jint* _GoJniGetIntArrayElements(JNIEnv* env, jintArray array, jboolean* isCopy);
+
+// jni.h:
+//     jlong * (JNICALL *GetLongArrayElements)(JNIEnv *env, jlongArray array, jboolean *isCopy);
+jlong* _GoJniGetLongArrayElements(JNIEnv* env, jlongArray array, jboolean* isCopy);
+
+// jni.h:
+//     jfloat * (JNICALL *GetFloatArrayElements)(JNIEnv *env, jfloatArray array, jboolean *isCopy);
+jfloat* _GoJniGetFloatArrayElements(JNIEnv* env, jfloatArray array, jboolean* isCopy);
+
+// jni.h:
+//     jdouble * (JNICALL *GetDoubleArrayElements)(JNIEnv *env, jdoubleArray array, jboolean *isCopy);
+jdouble* _GoJniGetDoubleArrayElements(JNIEnv* env, jdoubleArray array, jboolean* isCopy);
+
+// jni.h:
+//     void (JNICALL *ReleaseBooleanArrayElements)(JNIEnv *env, jbooleanArray array, jboolean *elems, jint mode);
+void _GoJniReleaseBooleanArrayElements(JNIEnv* env, jbooleanArray array, jboolean* elems, jint mode);
+
+// jni.h:
+//     void (JNICALL *ReleaseByteArrayElements)(JNIEnv *env, jbyteArray array, jbyte *elems, jint mode);
+void _GoJniReleaseByteArrayElements(JNIEnv* env, jbyteArray array, jbyte* elems, jint mode);
+
+// jni.h:
+//     void (JNICALL *ReleaseCharArrayElements)(JNIEnv *env, jcharArray array, jchar *elems, jint mode);
+void _GoJniReleaseCharArrayElements(JNIEnv* env, jcharArray array, jchar* elems, jint mode);
+
+// jni.h:
+//     void (JNICALL *ReleaseShortArrayElements)(JNIEnv *env, jshortArray array, jshort *elems, jint mode);
+void _GoJniReleaseShortArrayElements(JNIEnv* env, jshortArray array, jshort* elems, jint mode);
+
+// jni.h:
+//     void (JNICALL *ReleaseIntArrayElements)(JNIEnv *env, jintArray array, jint *elems, jint mode);
+void _GoJniReleaseIntArrayElements(JNIEnv* env, jintArray array, jint* elems, jint mode);
+
+// jni.h:
+//     void (JNICALL *ReleaseLongArrayElements)(JNIEnv *env, jlongArray array, jlong *elems, jint mode);
+void _GoJniReleaseLongArrayElements(JNIEnv* env, jlongArray array, jlong* elems, jint mode);
+
+// jni.h:
+//     void (JNICALL *ReleaseFloatArrayElements)(JNIEnv *env, jfloatArray array, jfloat *elems, jint mode);
+void _GoJniReleaseFloatArrayElements(JNIEnv* env, jfloatArray array, jfloat* elems, jint mode);
+
+// jni.h:
+//     void (JNICALL *ReleaseDoubleArrayElements)(JNIEnv *env, jdoubleArray array, jdouble *elems, jint mode);
+void _GoJniReleaseDoubleArrayElements(JNIEnv* env, jdoubleArray array, jdouble* elems, jint mode);
+
+// jni.h:
+//     void (JNICALL *GetBooleanArrayRegion)(JNIEnv *env, jbooleanArray array, jsize start, jsize l, jboolean *buf);
+void _GoJniGetBooleanArrayRegion(JNIEnv* env, jbooleanArray array, jsize start, jsize l, jboolean* buf);
+
+// jni.h:
+//     void (JNICALL *GetByteArrayRegion)(JNIEnv *env, jbyteArray array, jsize start, jsize len, jbyte *buf);
+void _GoJniGetByteArrayRegion(JNIEnv* env, jbyteArray array, jsize start, jsize len, jbyte* buf);
+
+// jni.h:
+//     void (JNICALL *GetCharArrayRegion)(JNIEnv *env, jcharArray array, jsize start, jsize len, jchar *buf);
+void _GoJniGetCharArrayRegion(JNIEnv* env, jcharArray array, jsize start, jsize len, jchar* buf);
+
+// jni.h:
+//     void (JNICALL *GetShortArrayRegion)(JNIEnv *env, jshortArray array, jsize start, jsize len, jshort *buf);
+void _GoJniGetShortArrayRegion(JNIEnv* env, jshortArray array, jsize start, jsize len, jshort* buf);
+
+// jni.h:
+//     void (JNICALL *GetIntArrayRegion)(JNIEnv *env, jintArray array, jsize start, jsize len, jint *buf);
+void _GoJniGetIntArrayRegion(JNIEnv* env, jintArray array, jsize start, jsize len, jint* buf);
+
+// jni.h:
+//     void (JNICALL *GetLongArrayRegion)(JNIEnv *env, jlongArray array, jsize start, jsize len, jlong *buf);
+void _GoJniGetLongArrayRegion(JNIEnv* env, jlongArray array, jsize start, jsize len, jlong* buf);
+
+// jni.h:
+//     void (JNICALL *GetFloatArrayRegion)(JNIEnv *env, jfloatArray array, jsize start, jsize len, jfloat *buf);
+void _GoJniGetFloatArrayRegion(JNIEnv* env, jfloatArray array, jsize start, jsize len, jfloat* buf);
+
+// jni.h:
+//     void (JNICALL *GetDoubleArrayRegion)(JNIEnv *env, jdoubleArray array, jsize start, jsize len, jdouble *buf);
+void _GoJniGetDoubleArrayRegion(JNIEnv* env, jdoubleArray array, jsize start, jsize len, jdouble* buf);
+
+// jni.h:
+//     void (JNICALL *SetBooleanArrayRegion)(JNIEnv *env, jbooleanArray array, jsize start, jsize l, const jboolean *buf);
+void _GoJniSetBooleanArrayRegion(JNIEnv* env, jbooleanArray array, jsize start, jsize l, const jboolean* buf);
+
+// jni.h:
+//     void (JNICALL *SetByteArrayRegion)(JNIEnv *env, jbyteArray array, jsize start, jsize len, const jbyte *buf);
+void _GoJniSetByteArrayRegion(JNIEnv* env, jbyteArray array, jsize start, jsize len, const jbyte* buf);
+
+// jni.h:
+//     void (JNICALL *SetCharArrayRegion)(JNIEnv *env, jcharArray array, jsize start, jsize len, const jchar *buf);
+void _GoJniSetCharArrayRegion(JNIEnv* env, jcharArray array, jsize start, jsize len, const jchar* buf);
+
+// jni.h:
+//     void (JNICALL *SetShortArrayRegion)(JNIEnv *env, jshortArray array, jsize start, jsize len, const jshort *buf);
+void _GoJniSetShortArrayRegion(JNIEnv* env, jshortArray array, jsize start, jsize len, const jshort* buf);
+
+// jni.h:
+//     void (JNICALL *SetIntArrayRegion)(JNIEnv *env, jintArray array, jsize start, jsize len, const jint *buf);
+void _GoJniSetIntArrayRegion(JNIEnv* env, jintArray array, jsize start, jsize len, const jint* buf);
+
+// jni.h:
+//     void (JNICALL *SetLongArrayRegion)(JNIEnv *env, jlongArray array, jsize start, jsize len, const jlong *buf);
+void _GoJniSetLongArrayRegion(JNIEnv* env, jlongArray array, jsize start, jsize len, const jlong* buf);
+
+// jni.h:
+//     void (JNICALL *SetFloatArrayRegion)(JNIEnv *env, jfloatArray array, jsize start, jsize len, const jfloat *buf);
+void _GoJniSetFloatArrayRegion(JNIEnv* env, jfloatArray array, jsize start, jsize len, const jfloat* buf);
+
+// jni.h:
+//     void (JNICALL *SetDoubleArrayRegion)(JNIEnv *env, jdoubleArray array, jsize start, jsize len, const jdouble *buf);
+void _GoJniSetDoubleArrayRegion(JNIEnv* env, jdoubleArray array, jsize start, jsize len, const jdouble* buf);
+
+// jni.h:
+//     jint (JNICALL *RegisterNatives)(JNIEnv *env, jclass clazz, const JNINativeMethod *methods, jint nMethods);
+jint _GoJniRegisterNatives(JNIEnv* env, jclass clazz, const JNINativeMethod* methods, jint nMethods);
+
+// jni.h:
+//     jint (JNICALL *UnregisterNatives)(JNIEnv *env, jclass clazz);
+jint _GoJniUnregisterNatives(JNIEnv* env, jclass clazz);
+
+// jni.h:
+//     jint (JNICALL *MonitorEnter)(JNIEnv *env, jobject obj);
+jint _GoJniMonitorEnter(JNIEnv* env, jobject obj);
+
+// jni.h:
+//     jint (JNICALL *MonitorExit)(JNIEnv *env, jobject obj);
+jint _GoJniMonitorExit(JNIEnv* env, jobject obj);
+
+// jni.h:
+//     jint (JNICALL *GetJavaVM)(JNIEnv *env, JavaVM **vm);
+jint _GoJniGetJavaVM(JNIEnv* env, JavaVM* * vm);
+
+// jni.h:
+//     void (JNICALL *GetStringRegion)(JNIEnv *env, jstring str, jsize start, jsize len, jchar *buf);
+void _GoJniGetStringRegion(JNIEnv* env, jstring str, jsize start, jsize len, jchar* buf);
+
+// jni.h:
+//     void (JNICALL *GetStringUTFRegion)(JNIEnv *env, jstring str, jsize start, jsize len, char *buf);
+void _GoJniGetStringUTFRegion(JNIEnv* env, jstring str, jsize start, jsize len, char* buf);
+
+// jni.h:
+//     void * (JNICALL *GetPrimitiveArrayCritical)(JNIEnv *env, jarray array, jboolean *isCopy);
+void* _GoJniGetPrimitiveArrayCritical(JNIEnv* env, jarray array, jboolean* isCopy);
+
+// jni.h:
+//     void (JNICALL *ReleasePrimitiveArrayCritical)(JNIEnv *env, jarray array, void *carray, jint mode);
+void _GoJniReleasePrimitiveArrayCritical(JNIEnv* env, jarray array, void* carray, jint mode);
+
+// jni.h:
+//     const jchar * (JNICALL *GetStringCritical)(JNIEnv *env, jstring string, jboolean *isCopy);
+const jchar* _GoJniGetStringCritical(JNIEnv* env, jstring string, jboolean* isCopy);
+
+// jni.h:
+//     void (JNICALL *ReleaseStringCritical)(JNIEnv *env, jstring string, const jchar *cstring);
+void _GoJniReleaseStringCritical(JNIEnv* env, jstring string, const jchar* cstring);
+
+// jni.h:
+//     jweak (JNICALL *NewWeakGlobalRef)(JNIEnv *env, jobject obj);
+jweak _GoJniNewWeakGlobalRef(JNIEnv* env, jobject obj);
+
+// jni.h:
+//     void (JNICALL *DeleteWeakGlobalRef)(JNIEnv *env, jweak ref);
+void _GoJniDeleteWeakGlobalRef(JNIEnv* env, jweak ref);
+
+// jni.h:
+//     jboolean (JNICALL *ExceptionCheck)(JNIEnv *env);
+jboolean _GoJniExceptionCheck(JNIEnv* env);
+
+// jni.h:
+//     jobject (JNICALL *NewDirectByteBuffer)(JNIEnv* env, void* address, jlong capacity);
+jobject _GoJniNewDirectByteBuffer(JNIEnv* env, void* address, jlong capacity);
+
+// jni.h:
+//     void* (JNICALL *GetDirectBufferAddress)(JNIEnv* env, jobject buf);
+void* _GoJniGetDirectBufferAddress(JNIEnv* env, jobject buf);
+
+// jni.h:
+//     jlong (JNICALL *GetDirectBufferCapacity)(JNIEnv* env, jobject buf);
+jlong _GoJniGetDirectBufferCapacity(JNIEnv* env, jobject buf);
+
+// jni.h:
+//     jobjectRefType (JNICALL *GetObjectRefType)(JNIEnv* env, jobject obj);
+jobjectRefType _GoJniGetObjectRefType(JNIEnv* env, jobject obj);
+
+#endif // #ifndef _GO_JNI_JNIENV_H_


[PATCH] ahci: separate out ahci_dev_classify

Separate out ahci_dev_classify().

Signed-off-by: Tejun Heo <ccfba69985e72fbcd9ba8bbb6db43d42971ad06d@gmail.com>
Signed-off-by: Jeff Garzik <15f615bf7d20c2937c7eb5aa759110fd6768848c@pobox.com>

--- drivers/scsi/ahci.c
+++ drivers/scsi/ahci.c
@@ -483,17 +483,11 @@
 	readl(port_mmio + PORT_CMD); /* flush */
 }

-static void ahci_phy_reset(struct ata_port *ap)
+static unsigned int ahci_dev_classify(struct ata_port *ap)
 {
 	void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr;
 	struct ata_taskfile tf;
-	struct ata_device *dev = &ap->device[0];
-	u32 new_tmp, tmp;
-
-	__sata_phy_reset(ap);
-
-	if (ap->flags & ATA_FLAG_PORT_DISABLED)
-		return;
+	u32 tmp;

 	tmp = readl(port_mmio + PORT_SIG);
 	tf.lbah		= (tmp >> 24)	& 0xff;
@@ -501,7 +495,21 @@
 	tf.lbal		= (tmp >> 8)	& 0xff;
 	tf.nsect	= (tmp)		& 0xff;

-	dev->class = ata_dev_classify(&tf);
+	return ata_dev_classify(&tf);
+}
+
+static void ahci_phy_reset(struct ata_port *ap)
+{
+	void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr;
+	struct ata_device *dev = &ap->device[0];
+	u32 new_tmp, tmp;
+
+	__sata_phy_reset(ap);
+
+	if (ap->flags & ATA_FLAG_PORT_DISABLED)
+		return;
+
+	dev->class = ahci_dev_classify(ap);
 	if (!ata_dev_present(dev)) {
 		ata_port_disable(ap);
 		return;


cgpt: create: Don't modify existing IGNOREME headers

Respect any existing IGNOREME signatures and do not attempt to make any
modifications until a user has explicitly removed this flag via cgpt
legacy or other method.

BRANCH=None
BUG=chromium:948742
TEST=chromeos-install on veyron_minnie with 4.19 kernel

Change-Id: I110a95ee0c136ebbe2274139deebcaacde712e80
Signed-off-by: Ryan Case <26b4b6d684cc4b09b373db8343683bb38dc57f9e@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1572440
Commit-Ready: Ryan Case <26b4b6d684cc4b09b373db8343683bb38dc57f9e@google.com>
Tested-by: Ryan Case <26b4b6d684cc4b09b373db8343683bb38dc57f9e@google.com>
Reviewed-by: Julius Werner <4d12f06cff3725783b352157673a720bc67c4afe@chromium.org>


fixed bug

fixed bug

Signed-off-by: Jens Nyberg <7200009990a46d4bb36e24284136c70d739d75fd@gmail.com>

--- lib/event/base.c
+++ lib/event/base.c
@@ -53,16 +53,13 @@
 {

     struct event_header *reply = buffer;
-    /*
-    struct event_forward *forward = event_getforward(buffer);
-    */

     event_addheader(buffer, type, header->target, header->source);

-    /*
     if (header->forward)
     {

+        struct event_forward *forward = event_getforward(header);
         unsigned int i;

         for (i = 1; i < header->forward; i++)
@@ -71,7 +68,6 @@
         reply->target = forward[0].target;

     }
-    */

     return reply->length;


[SCSI] Return VPD page length in scsi_vpd_inquiry()

We should be returning the number of bytes of the
requested VPD page in scsi_vpd_inquiry.
This makes it easier for the caller to verify the
required space.

[jejb: fix up mm warning spotted by Sergey]
Tested-by: Sergey Senozhatsky <d9c384f6b6e27869ff3b53bd225c29030ac4166b@gmail.com>
Signed-off-by: Hannes Reinecke <b0d1e9e4a4e27620745ff49be9000da3174a4cc6@suse.de>
Signed-off-by: James Bottomley <1acebbdca565c7b6b638bdc23b58b5610d1a56b8@Parallels.com>

--- drivers/scsi/scsi.c
+++ drivers/scsi/scsi.c
@@ -942,13 +942,16 @@
  * This is an internal helper function.  You probably want to use
  * scsi_get_vpd_page instead.
  *
- * Returns 0 on success or a negative error number.
+ * Returns size of the vpd page on success or a negative error number.
  */
 static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer,
 							u8 page, unsigned len)
 {
 	int result;
 	unsigned char cmd[16];
+
+	if (len < 4)
+		return -EINVAL;

 	cmd[0] = INQUIRY;
 	cmd[1] = 1;		/* EVPD */
@@ -964,13 +967,13 @@
 	result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer,
 				  len, NULL, 30 * HZ, 3, NULL);
 	if (result)
-		return result;
+		return -EIO;

 	/* Sanity check that we got the page back that we asked for */
 	if (buffer[1] != page)
 		return -EIO;

-	return 0;
+	return get_unaligned_be16(&buffer[2]) + 4;
 }

 /**
@@ -997,18 +1000,18 @@

 	/* Ask for all the pages supported by this device */
 	result = scsi_vpd_inquiry(sdev, buf, 0, buf_len);
-	if (result)
+	if (result < 4)
 		goto fail;

 	/* If the user actually wanted this page, we can skip the rest */
 	if (page == 0)
 		return 0;

-	for (i = 0; i < min((int)buf[3], buf_len - 4); i++)
-		if (buf[i + 4] == page)
+	for (i = 4; i < min(result, buf_len); i++)
+		if (buf[i] == page)
 			goto found;

-	if (i < buf[3] && i >= buf_len - 4)
+	if (i < result && i >= buf_len)
 		/* ran off the end of the buffer, give us benefit of doubt */
 		goto found;
 	/* The device claims it doesn't support the requested page */
@@ -1016,7 +1019,7 @@

  found:
 	result = scsi_vpd_inquiry(sdev, buf, page, buf_len);
-	if (result)
+	if (result < 0)
 		goto fail;

 	return 0;


[SCSI] Don't attempt to send extended INQUIRY command if skip_vpd_pages is set

If a device has the skip_vpd_pages flag set we should simply fail the
scsi_get_vpd_page() call.

Signed-off-by: Martin K. Petersen <0384aaef27f06874adbdb09a807bb339f4aff9fd@oracle.com>
Acked-by: Alan Stern <75ea6bb7bfc1186f92d26164de5f9268c9a45b59@rowland.harvard.edu>
Tested-by: Stuart Foster <060449e47b4fbc4809c9018f37c3ae54792344ca@ntlworld.com>
Cc: 4fbacc2fa0ffdbb11bf1ad6925b886ebd08dd15f@vger.kernel.org
Signed-off-by: James Bottomley <1acebbdca565c7b6b638bdc23b58b5610d1a56b8@Parallels.com>

--- drivers/scsi/scsi.c
+++ drivers/scsi/scsi.c
@@ -1031,6 +1031,9 @@
 {
 	int i, result;

+	if (sdev->skip_vpd_pages)
+		goto fail;
+
 	/* Ask for all the pages supported by this device */
 	result = scsi_vpd_inquiry(sdev, buf, 0, buf_len);
 	if (result)


[SCSI] stex: use resid for xfer len information

The original implementation in stex_ys_commands() is inappropriate.
For xfer len information, we should use resid instead.

Signed-off-by: Ed Lin <c9dbd4ab75a2d1148413e552653a05e34df700fd@promise.com>
Signed-off-by: James Bottomley <407b36959ca09543ccda8f8e06721c791bc53435@SteelEye.com>

--- drivers/scsi/stex.c
+++ drivers/scsi/stex.c
@@ -719,8 +719,8 @@

 	if (ccb->cmd->cmnd[0] == MGT_CMD &&
 		resp->scsi_status != SAM_STAT_CHECK_CONDITION) {
-		scsi_bufflen(ccb->cmd) =
-			le32_to_cpu(*(__le32 *)&resp->variable[0]);
+		scsi_set_resid(ccb->cmd, scsi_bufflen(ccb->cmd) -
+			le32_to_cpu(*(__le32 *)&resp->variable[0]));
 		return;
 	}


Fix typos..  The vector for "int 0x12" (get base mem) is not written in hex as "0x1a". :-) Fix a comment about the extended memory checks, that's int 0x15.


n_tty: Access termios values safely

n_tty: Access termios values safely

Use termios_rwsem to guarantee safe access to the termios values.
This is particularly important for N_TTY as changing certain termios
settings alters the mode of operation.

termios_rwsem must be dropped across throttle/unthrottle since
those functions claim the termios_rwsem exclusively (to guarantee
safe access to the termios and for mutual exclusion).

Signed-off-by: Peter Hurley <4b8373d016f277527198385ba72fda0feb5da015@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- drivers/tty/n_tty.c
+++ drivers/tty/n_tty.c
@@ -1491,10 +1491,14 @@
 	 * canonical mode and don't have a newline yet!
 	 */
 	while (1) {
+		int throttled;
 		tty_set_flow_change(tty, TTY_THROTTLE_SAFE);
 		if (receive_room(tty) >= TTY_THRESHOLD_THROTTLE)
 			break;
-		if (!tty_throttle_safe(tty))
+		up_read(&tty->termios_rwsem);
+		throttled = tty_throttle_safe(tty);
+		down_read(&tty->termios_rwsem);
+		if (!throttled)
 			break;
 	}
 	__tty_set_flow_change(tty, 0);
@@ -1503,7 +1507,9 @@
 static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
 			      char *fp, int count)
 {
+	down_read(&tty->termios_rwsem);
 	__receive_buf(tty, cp, fp, count);
+	up_read(&tty->termios_rwsem);
 }

 static int n_tty_receive_buf2(struct tty_struct *tty, const unsigned char *cp,
@@ -1511,6 +1517,8 @@
 {
 	struct n_tty_data *ldata = tty->disc_data;
 	int room;
+
+	down_read(&tty->termios_rwsem);

 	tty->receive_room = room = receive_room(tty);
 	if (!room)
@@ -1518,6 +1526,8 @@
 	count = min(count, room);
 	if (count)
 		__receive_buf(tty, cp, fp, count);
+
+	up_read(&tty->termios_rwsem);

 	return count;
 }
@@ -1934,6 +1944,8 @@
 	if (c < 0)
 		return c;

+	down_read(&tty->termios_rwsem);
+
 	minimum = time = 0;
 	timeout = MAX_SCHEDULE_TIMEOUT;
 	if (!ldata->icanon) {
@@ -1955,11 +1967,15 @@
 	 *	Internal serialization of reads.
 	 */
 	if (file->f_flags & O_NONBLOCK) {
-		if (!mutex_trylock(&ldata->atomic_read_lock))
+		if (!mutex_trylock(&ldata->atomic_read_lock)) {
+			up_read(&tty->termios_rwsem);
 			return -EAGAIN;
+		}
 	} else {
-		if (mutex_lock_interruptible(&ldata->atomic_read_lock))
+		if (mutex_lock_interruptible(&ldata->atomic_read_lock)) {
+			up_read(&tty->termios_rwsem);
 			return -ERESTARTSYS;
+		}
 	}
 	packet = tty->packet;

@@ -2009,7 +2025,11 @@
 				break;
 			}
 			n_tty_set_room(tty);
+			up_read(&tty->termios_rwsem);
+
 			timeout = schedule_timeout(timeout);
+
+			down_read(&tty->termios_rwsem);
 			continue;
 		}
 		__set_current_state(TASK_RUNNING);
@@ -2048,13 +2068,17 @@
 		 * we won't get any more characters.
 		 */
 		while (1) {
+			int unthrottled;
 			tty_set_flow_change(tty, TTY_UNTHROTTLE_SAFE);
 			if (chars_in_buffer(tty) > TTY_THRESHOLD_UNTHROTTLE)
 				break;
 			if (!tty->count)
 				break;
 			n_tty_set_room(tty);
-			if (!tty_unthrottle_safe(tty))
+			up_read(&tty->termios_rwsem);
+			unthrottled = tty_unthrottle_safe(tty);
+			down_read(&tty->termios_rwsem);
+			if (!unthrottled)
 				break;
 		}
 		__tty_set_flow_change(tty, 0);
@@ -2076,10 +2100,13 @@
 		retval = size;
 		if (nr)
 			clear_bit(TTY_PUSH, &tty->flags);
-	} else if (test_and_clear_bit(TTY_PUSH, &tty->flags))
+	} else if (test_and_clear_bit(TTY_PUSH, &tty->flags)) {
+		up_read(&tty->termios_rwsem);
 		goto do_it_again;
+	}

 	n_tty_set_room(tty);
+	up_read(&tty->termios_rwsem);
 	return retval;
 }

@@ -2119,6 +2146,8 @@
 		if (retval)
 			return retval;
 	}
+
+	down_read(&tty->termios_rwsem);

 	/* Write out any echoed characters that are still pending */
 	process_echoes(tty);
@@ -2173,13 +2202,18 @@
 			retval = -EAGAIN;
 			break;
 		}
+		up_read(&tty->termios_rwsem);
+
 		schedule();
+
+		down_read(&tty->termios_rwsem);
 	}
 break_out:
 	__set_current_state(TASK_RUNNING);
 	remove_wait_queue(&tty->write_wait, &wait);
 	if (b - buf != nr && tty->fasync)
 		set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
+	up_read(&tty->termios_rwsem);
 	return (b - buf) ? b - buf : retval;
 }


Compute the right length to use with bzero() when initializing an IRP in IoInitializeIrp() (must use IoSizeOfIrp() to account for the stack locations).

--- sys/compat/ndis/subr_ntoskrnl.c
+++ sys/compat/ndis/subr_ntoskrnl.c
@@ -760,7 +760,7 @@
 	uint16_t		psize;
 	uint8_t			ssize;
 {
-	bzero((char *)io, sizeof(irp));
+	bzero((char *)io, IoSizeOfIrp(ssize));
 	io->irp_size = psize;
 	io->irp_stackcnt = ssize;
 	io->irp_currentstackloc = ssize;


Fix self-strncmp in ConstrIsFKToReferenceTable

Make the function do what I assume was intended.

--- src/backend/distributed/commands/foreign_constraint.c
+++ src/backend/distributed/commands/foreign_constraint.c
@@ -42,7 +42,7 @@
  * of them is a foreign key referencing to a reference table.
  */
 bool
-ConstraintIsAForeignKeyToReferenceTable(char *constraintName, Oid relationId)
+ConstraintIsAForeignKeyToReferenceTable(char *constraintNameInput, Oid relationId)
 {
 	Relation pgConstraint = NULL;
 	SysScanDesc scanDescriptor = NULL;
@@ -66,7 +66,7 @@
 		Form_pg_constraint constraintForm = (Form_pg_constraint) GETSTRUCT(heapTuple);
 		char *constraintName = (constraintForm->conname).data;

-		if (strncmp(constraintName, constraintName, NAMEDATALEN) != 0 ||
+		if (strncmp(constraintNameInput, constraintName, NAMEDATALEN) != 0 ||
 			constraintForm->conrelid != relationId)
 		{
 			heapTuple = systable_getnext(scanDescriptor);


n_tty: Eliminate receive_room() from consumer/exclusive paths

The input worker never reschedules itself; it only processes input until
either there is no more input or the read buffer is full. So the reader
is responsible for restarting the input worker only if the read buffer
was previously full (no_room == 1) _and_ space is now available to process
more input because the reader has consumed data from the read buffer.

However, computing the actual space available is not required to determine
if the reader has consumed data from the read buffer. This condition is
evaluated in 5 situations, each of which the space avail is already known:
1. n_tty_flush_buffer() - the read buffer is empty; kick the worker
2. n_tty_set_termios() - no data has been consumed; do not kick the worker
       (although it may have kicked the reader so data _will be_ consumed)
3. n_tty_check_unthrottle - avail space > 3968; kick the worker
4. n_tty_read, before leaving - only kick the worker if the reader has
       moved the tail. This prevents unnecessarily kicking the worker
       when timeout-style reading is used.
5. n_tty_read, before sleeping - although it is possible for the read
       buffer to be full and input_available_p() to be false, this can
       only happen when the input worker is racing the reader, in which
       case the reader will have been woken and won't sleep.

Rename n_tty_set_room() to n_tty_kick_worker() to reflect what the
function actually does.

Signed-off-by: Peter Hurley <4b8373d016f277527198385ba72fda0feb5da015@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- drivers/tty/n_tty.c
+++ drivers/tty/n_tty.c
@@ -187,10 +187,10 @@
 }

 /**
- *	n_tty_set_room	-	receive space
+ *	n_tty_kick_worker - start input worker (if required)
  *	@tty: terminal
  *
- *	Re-schedules the flip buffer work if space just became available.
+ *	Re-schedules the flip buffer work if it may have stopped
  *
  *	Caller holds exclusive termios_rwsem
  *	   or
@@ -198,12 +198,12 @@
  *		holds non-exclusive termios_rwsem
  */

-static void n_tty_set_room(struct tty_struct *tty)
-{
-	struct n_tty_data *ldata = tty->disc_data;
-
-	/* Did this open up the receive buffer? We may need to flip */
-	if (unlikely(ldata->no_room) && receive_room(tty)) {
+static void n_tty_kick_worker(struct tty_struct *tty)
+{
+	struct n_tty_data *ldata = tty->disc_data;
+
+	/* Did the input worker stop? Restart it */
+	if (unlikely(ldata->no_room)) {
 		ldata->no_room = 0;

 		WARN_RATELIMIT(tty->port->itty == NULL,
@@ -274,7 +274,7 @@
 			return;
 		if (!tty->count)
 			return;
-		n_tty_set_room(tty);
+		n_tty_kick_worker(tty);
 		n_tty_write_wakeup(tty->link);
 		if (waitqueue_active(&tty->link->write_wait))
 			wake_up_interruptible_poll(&tty->link->write_wait, POLLOUT);
@@ -296,7 +296,7 @@
 			break;
 		if (!tty->count)
 			break;
-		n_tty_set_room(tty);
+		n_tty_kick_worker(tty);
 		unthrottled = tty_unthrottle_safe(tty);
 		if (!unthrottled)
 			break;
@@ -379,7 +379,7 @@
 {
 	down_write(&tty->termios_rwsem);
 	reset_buffer_flags(tty->disc_data);
-	n_tty_set_room(tty);
+	n_tty_kick_worker(tty);

 	if (tty->link)
 		n_tty_packet_mode_flush(tty);
@@ -1817,7 +1817,6 @@
 		else
 			ldata->real_raw = 0;
 	}
-	n_tty_set_room(tty);
 	/*
 	 * Fix tty hang when I_IXON(tty) is cleared, but the tty
 	 * been stopped by STOP_CHAR(tty) before it.
@@ -2130,6 +2129,7 @@
 	ssize_t retval = 0;
 	long timeout;
 	int packet;
+	size_t tail;

 	c = job_control(tty, file);
 	if (c < 0)
@@ -2166,6 +2166,7 @@
 	}

 	packet = tty->packet;
+	tail = ldata->read_tail;

 	add_wait_queue(&tty->read_wait, &wait);
 	while (nr) {
@@ -2208,7 +2209,6 @@
 				retval = -ERESTARTSYS;
 				break;
 			}
-			n_tty_set_room(tty);
 			up_read(&tty->termios_rwsem);

 			timeout = wait_woken(&wait, TASK_INTERRUPTIBLE,
@@ -2253,7 +2253,8 @@
 		if (time)
 			timeout = time;
 	}
-	n_tty_set_room(tty);
+	if (tail != ldata->read_tail)
+		n_tty_kick_worker(tty);
 	up_read(&tty->termios_rwsem);

 	remove_wait_queue(&tty->read_wait, &wait);


Import a mostly rewritten and extended version of acpi_ibm:

- Restructured for easier extensibility and maintainability
- To be more uniform with the other ACPI extras drivers and to better reflect
  their actual meaning, some sysctls were moved:
    o brightness -> lcd_brightness
    o keylight   -> thinklight
    o enable     -> events
    o misckey    -> hotkey
    o avail_mask -> availmask
    o key_mask   -> eventmask
- New "initialmask" sysctl, which holds the initial eventmask
- The "wlan" sysctl is now read-only, since writing to it didn't have
  any effect
- The "version" sysctl was removed, since it seems to be the same (0x100)
  on all models I have seen
- Support for more hotkeys by the "hotkey" sysctl
- Improved support of ACPI events. Disabled by default, since it unexpectedly
  changes the behaviour of some keys. (on my T41p there are now 24 different
  keypress events that get reported)
- write support for: volume, mute, lcd_brightness and thinklight
- led(4) interface for the thinklight [1]
- New sysctls "fan" and "fan_speed" to support reading of fan status and speed
- New sysctl "thermal" to support reading of up to 8 thermal sensors

Reviewed by:	philip
Approved by:	philip
Submitted by:	simon [1]
Inspired by:	The Linux ibm_acpi driver by Borislav Deianov
		  http://ibm-acpi.sourceforge.net/
		The ThinkPad Button program (tpb) by Markus Braun
		  http://www.nongnu.org/tpb/
Thanks to:	brueffer, dvl, njl, philip, simon, takawata and the many
		testers from freebsd-acpi@ and freebsd-mobile@

--- sys/dev/acpi_support/acpi_ibm.c
+++ sys/dev/acpi_support/acpi_ibm.c
@@ -1,5 +1,6 @@
 /*-
  * Copyright (c) 2004 Takanori Watanabe
+ * Copyright (c) 2005 Markus Brueffer <markus@FreeBSD.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,6 +28,15 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");

+/*
+ * Driver for extra ACPI-controlled gadgets found on IBM ThinkPad laptops.
+ * Inspired by the ibm-acpi and tpb projects which implement these features
+ * on Linux.
+ *
+ *   acpi-ibm: <http://ibm-acpi.sourceforge.net/>
+ *        tpb: <http://www.nongnu.org/tpb/>
+ */
+
 #include "opt_acpi.h"
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -36,68 +46,208 @@
 #include "acpi_if.h"
 #include <sys/module.h>
 #include <dev/acpica/acpivar.h>
+#include <dev/led/led.h>
 #include <sys/sysctl.h>
 #include <machine/clock.h>

 #define _COMPONENT	ACPI_OEM
 ACPI_MODULE_NAME("IBM")

-#define IBM_RTC_MISCKEY 0x65
-#define IBM_RTC_BRIGHTNESS 0x6c
-#define   IBM_RTC_MASK_BRI 0x7
-#define   IBM_RTC_MASK_BRKEY 0x40
-#define IBM_RTC_KEYLIGHT 0x66
-#define   IBM_RTC_MASK_KEYLIGHT 0x10
-#define IBM_RTC_VOLUME 0x6e
-#define   IBM_RTC_MASK_VOL 0xf
-#define   IBM_RTC_MASK_MUTE 0x40
-#define   IBM_RTC_MASK_VOLKEY 0x80
-
-#define IBM_NAME_GET_WIRELESS "GBDC"
-#define IBM_NAME_SET_WIRELESS "SBDC"
-#define IBM_NAME_INTERFACE_VERSION "MHKV"
-#define IBM_NAME_AVAIL_MASK "MHKA"
-#define IBM_NAME_CURRENT_MASK "MHKN"
-#define IBM_NAME_MODIFY_MASK "MHKM"
-#define IBM_NAME_GET_EVENT "MHKP"
-#define IBM_NAME_ENABLE "MHKC"
-#if 0
-/* TPX31 Specific? */
-#define IBM_UCMS_VOLDN 0x0
-#define IBM_UCMS_VOLUP 0x1
-#define IBM_UCMS_MUTE 0x2
-#define IBM_UCMS_BRIUP 0x4
-#define IBM_UCMS_BRIDN 0x5
-#define IBM_UCMS_KEYLIGHT 0xe
-#endif
+/* Internal methods */
+#define ACPI_IBM_METHOD_EVENTS		1
+#define ACPI_IBM_METHOD_EVENTMASK	2
+#define ACPI_IBM_METHOD_HOTKEY		3
+#define ACPI_IBM_METHOD_BRIGHTNESS	4
+#define ACPI_IBM_METHOD_VOLUME		5
+#define ACPI_IBM_METHOD_MUTE		6
+#define ACPI_IBM_METHOD_THINKLIGHT	7
+#define ACPI_IBM_METHOD_BLUETOOTH	8
+#define ACPI_IBM_METHOD_WLAN		9
+#define ACPI_IBM_METHOD_FANSPEED	10
+#define ACPI_IBM_METHOD_FANSTATUS	11
+#define ACPI_IBM_METHOD_THERMAL		12
+
+/* Hotkeys/Buttons */
+#define IBM_RTC_HOTKEY1			0x64
+#define   IBM_RTC_MASK_HOME		(1 << 0)
+#define   IBM_RTC_MASK_SEARCH		(1 << 1)
+#define   IBM_RTC_MASK_MAIL		(1 << 2)
+#define   IBM_RTC_MASK_WLAN		(1 << 5)
+#define IBM_RTC_HOTKEY2			0x65
+#define   IBM_RTC_MASK_THINKPAD		(1 << 3)
+#define   IBM_RTC_MASK_ZOOM		(1 << 5)
+#define   IBM_RTC_MASK_VIDEO		(1 << 6)
+#define   IBM_RTC_MASK_HIBERNATE	(1 << 7)
+#define IBM_RTC_THINKLIGHT		0x66
+#define   IBM_RTC_MASK_THINKLIGHT	(1 << 4)
+#define IBM_RTC_SCREENEXPAND		0x67
+#define   IBM_RTC_MASK_SCREENEXPAND	(1 << 5)
+#define IBM_RTC_BRIGHTNESS		0x6c
+#define   IBM_RTC_MASK_BRIGHTNESS	(1 << 5)
+#define IBM_RTC_VOLUME			0x6e
+#define   IBM_RTC_MASK_VOLUME		(1 << 7)
+
+/* Embedded Controller registers */
+#define IBM_EC_BRIGHTNESS		0x31
+#define   IBM_EC_MASK_BRI		0x7
+#define IBM_EC_VOLUME			0x30
+#define   IBM_EC_MASK_VOL		0xf
+#define   IBM_EC_MASK_MUTE		(1 << 6)
+#define IBM_EC_FANSTATUS		0x2F
+#define   IBM_EC_MASK_FANSTATUS		(1 << 7)
+#define IBM_EC_FANSPEED			0x84
+
+/* CMOS Commands */
+#define IBM_CMOS_VOLUME_DOWN		0
+#define IBM_CMOS_VOLUME_UP		1
+#define IBM_CMOS_VOLUME_MUTE		2
+#define IBM_CMOS_BRIGHTNESS_UP		4
+#define IBM_CMOS_BRIGHTNESS_DOWN	5
+
+/* ACPI methods */
+#define IBM_NAME_KEYLIGHT		"KBLT"
+#define IBM_NAME_WLAN_BT_GET		"GBDC"
+#define IBM_NAME_WLAN_BT_SET		"SBDC"
+#define   IBM_NAME_MASK_BT		(1 << 1)
+#define   IBM_NAME_MASK_WLAN		(1 << 2)
+#define IBM_NAME_THERMAL_GET		"TMP7"
+#define IBM_NAME_THERMAL_UPDT		"UPDT"
+
+#define IBM_NAME_EVENTS_STATUS_GET	"DHKC"
+#define IBM_NAME_EVENTS_MASK_GET	"DHKN"
+#define IBM_NAME_EVENTS_STATUS_SET	"MHKC"
+#define IBM_NAME_EVENTS_MASK_SET	"MHKM"
+#define IBM_NAME_EVENTS_GET		"MHKP"
+#define IBM_NAME_EVENTS_AVAILMASK	"MHKA"
+
+#define ABS(x) (((x) < 0)? -(x) : (x))

 struct acpi_ibm_softc {
-	unsigned int	ibm_version;
-	unsigned int	ibm_availmask;
-	unsigned int	ibm_initialmask;
-	int		ibm_enable;
-	int		device_flag;
-#define IBM_MHKN_AVAIL 1
-#define IBM_MHKM_AVAIL 2
-	struct sysctl_oid *oid_bluetooth;
-	struct sysctl_oid *oid_wlan;
+	device_t	dev;
+	ACPI_HANDLE	handle;
+
+	/* Embedded controller */
+	device_t	ec_dev;
+	ACPI_HANDLE	ec_handle;
+
+	/* CMOS */
+	ACPI_HANDLE	cmos_handle;
+
+	/* Fan status */
+	ACPI_HANDLE	fan_handle;
+	int		fan_levels;
+
+	/* Keylight commands and states */
+	ACPI_HANDLE	light_handle;
+	int		light_cmd_on;
+	int		light_cmd_off;
+	int		light_val;
+	int		light_get_supported;
+	int		light_set_supported;
+	struct cdev	*led_dev;
+
+	int		wlan_bt_flags;
+	int		thermal_updt_supported;
+
+	unsigned int	events_availmask;
+	unsigned int	events_initialmask;
+	int		events_mask_supported;
+	int		events_enable;
+
+	struct sysctl_ctx_list	*sysctl_ctx;
+	struct sysctl_oid	*sysctl_tree;
 };
+
+static struct {
+	char	*name;
+	int	method;
+	char	*description;
+	int	access;
+} acpi_ibm_sysctls[] = {
+	{
+		.name		= "events",
+		.method		= ACPI_IBM_METHOD_EVENTS,
+		.description	= "ACPI events enable",
+		.access		= CTLTYPE_INT | CTLFLAG_RW
+	},
+	{
+		.name		= "eventmask",
+		.method		= ACPI_IBM_METHOD_EVENTMASK,
+		.description	= "ACPI eventmask",
+		.access		= CTLTYPE_INT | CTLFLAG_RW
+	},
+	{
+		.name		= "hotkey",
+		.method		= ACPI_IBM_METHOD_HOTKEY,
+		.description	= "Key Status",
+		.access		= CTLTYPE_INT | CTLFLAG_RD
+	},
+	{
+		.name		= "lcd_brightness",
+		.method		= ACPI_IBM_METHOD_BRIGHTNESS,
+		.description	= "LCD Brightness",
+		.access		= CTLTYPE_INT | CTLFLAG_RW
+	},
+	{
+		.name		= "volume",
+		.method		= ACPI_IBM_METHOD_VOLUME,
+		.description	= "Volume",
+		.access		= CTLTYPE_INT | CTLFLAG_RW
+	},
+	{
+		.name		= "mute",
+		.method		= ACPI_IBM_METHOD_MUTE,
+		.description	= "Mute",
+		.access		= CTLTYPE_INT | CTLFLAG_RW
+	},
+	{
+		.name		= "thinklight",
+		.method		= ACPI_IBM_METHOD_THINKLIGHT,
+		.description	= "Thinklight enable",
+		.access		= CTLTYPE_INT | CTLFLAG_RW
+	},
+	{
+		.name		= "bluetooth",
+		.method		= ACPI_IBM_METHOD_BLUETOOTH,
+		.description	= "Bluetooth enable",
+		.access		= CTLTYPE_INT | CTLFLAG_RW
+	},
+	{
+		.name		= "wlan",
+		.method		= ACPI_IBM_METHOD_WLAN,
+		.description	= "WLAN enable",
+		.access		= CTLTYPE_INT | CTLFLAG_RD
+	},
+	{
+		.name		= "fan_speed",
+		.method		= ACPI_IBM_METHOD_FANSPEED,
+		.description	= "Fan speed",
+		.access		= CTLTYPE_INT | CTLFLAG_RD
+	},
+	{
+		.name		= "fan",
+		.method		= ACPI_IBM_METHOD_FANSTATUS,
+		.description	= "Fan enable",
+		.access		= CTLTYPE_INT | CTLFLAG_RD
+	},
+
+	{ NULL, 0, NULL, 0 }
+};
+
+ACPI_SERIAL_DECL(ibm, "ACPI IBM extras");

 static int	acpi_ibm_probe(device_t dev);
 static int	acpi_ibm_attach(device_t dev);
 static int	acpi_ibm_detach(device_t dev);
-static void
-acpi_ibm_notify_handler(ACPI_HANDLE h, UINT32 notify,
-			void *context);
-static int	sysctl_acpi_ibm_mask_handler(SYSCTL_HANDLER_ARGS);
-static int	sysctl_acpi_ibm_enable_handler(SYSCTL_HANDLER_ARGS);
-static int	sysctl_acpi_ibm_misckey_handler(SYSCTL_HANDLER_ARGS);
-static int	sysctl_acpi_ibm_volume_handler(SYSCTL_HANDLER_ARGS);
-static int	sysctl_acpi_ibm_mute_handler(SYSCTL_HANDLER_ARGS);
-static int	sysctl_acpi_ibm_brightness_handler(SYSCTL_HANDLER_ARGS);
-static int	sysctl_acpi_ibm_keylight_handler(SYSCTL_HANDLER_ARGS);
-static int	sysctl_acpi_ibm_wireless_handler(SYSCTL_HANDLER_ARGS);
-static int	acpi_ibm_enable_mask(device_t dev, int val);
+
+static int	acpi_ibm_sysctl(SYSCTL_HANDLER_ARGS);
+static int	acpi_ibm_sysctl_init(struct acpi_ibm_softc *sc, int method);
+static int	acpi_ibm_sysctl_get(struct acpi_ibm_softc *sc, int method);
+static int	acpi_ibm_sysctl_set(struct acpi_ibm_softc *sc, int method, int val);
+
+static int	acpi_ibm_eventmask_set(struct acpi_ibm_softc *sc, int val);
+static int	acpi_ibm_thermal_sysctl(SYSCTL_HANDLER_ARGS);
+static void	acpi_ibm_notify(ACPI_HANDLE h, UINT32 notify, void *context);

 static device_method_t acpi_ibm_methods[] = {
 	/* Device interface */
@@ -119,138 +269,116 @@
 DRIVER_MODULE(acpi_ibm, acpi, acpi_ibm_driver, acpi_ibm_devclass,
 	      0, 0);
 MODULE_DEPEND(acpi_ibm, acpi, 1, 1, 1);
-static char    *ibm_id[] = {"IBM0068", NULL};
+static char    *ibm_ids[] = {"IBM0068", NULL};
+
+static void
+ibm_led(void *softc, int onoff)
+{
+	ACPI_SERIAL_BEGIN(ibm);
+	acpi_ibm_sysctl_set((struct acpi_ibm_softc*)softc,
+	    ACPI_IBM_METHOD_THINKLIGHT, onoff);
+	ACPI_SERIAL_END(ibm);
+}

 static int
 acpi_ibm_probe(device_t dev)
 {
-	struct acpi_ibm_softc *sc;
-	int		ret = ENXIO;
-
-	sc = device_get_softc(dev);
-
-	if (ACPI_ID_PROBE(device_get_parent(dev), dev, ibm_id)) {
-		device_set_desc(dev, "IBM ThinkPad Button");
-		ret = 0;
-	}
-	return (ret);
-}
-
-static int
-acpi_ibm_call_two_method(device_t dev, char *name, int val1, int val2)
-{
-	ACPI_OBJECT	arg [2];
-	ACPI_OBJECT_LIST args = {.Count = 2,.Pointer = arg};
-	arg[0].Type = ACPI_TYPE_INTEGER;
-	arg[0].Integer.Value = val1;
-	arg[1].Type = ACPI_TYPE_INTEGER;
-	arg[1].Integer.Value = val2;
-	return AcpiEvaluateObject(acpi_get_handle(dev), name, &args, NULL);
+	if (acpi_disabled("ibm") ||
+	    ACPI_ID_PROBE(device_get_parent(dev), dev, ibm_ids) == NULL ||
+	    device_get_unit(dev) != 0)
+		return (ENXIO);
+
+	device_set_desc(dev, "IBM ThinkPad ACPI Extras");
+
+	return (0);
 }

 static int
 acpi_ibm_attach(device_t dev)
 {
-	struct acpi_ibm_softc *sc;
-	ACPI_STATUS	status;
-	ACPI_HANDLE	h;
-	int		dummy;
-	struct sysctl_oid *oid;
+	struct acpi_ibm_softc	*sc;
+	struct acpi_softc	*acpi_sc;
+	devclass_t		ec_devclass;
+
 	ACPI_FUNCTION_TRACE((char *)(uintptr_t) __func__);

 	sc = device_get_softc(dev);
-	sc->device_flag = 0;
-	if (ACPI_FAILURE
-	    (acpi_GetInteger(acpi_get_handle(dev), IBM_NAME_INTERFACE_VERSION, &sc->ibm_version))) {
-		sc->ibm_version = 0;
-	}
-	device_printf(dev, "Version %x\n", sc->ibm_version);
-	if (ACPI_FAILURE
-	    (acpi_GetInteger(acpi_get_handle(dev), IBM_NAME_AVAIL_MASK, &sc->ibm_availmask)))
-		sc->ibm_availmask = 0xffffffff;
-
-	if (ACPI_FAILURE
-	    (acpi_GetInteger(acpi_get_handle(dev), IBM_NAME_CURRENT_MASK, &sc->ibm_initialmask)))
-		sc->ibm_initialmask = 0xffffffff;
-	else
-		sc->device_flag |= IBM_MHKN_AVAIL;
-
-	if (ACPI_SUCCESS(status = AcpiGetHandle(acpi_get_handle(dev), IBM_NAME_MODIFY_MASK, &h)))
-		sc->device_flag |= IBM_MHKM_AVAIL;
-	else
-		printf("%s\n", AcpiFormatException(status));
-
-	device_printf(dev, "Available Mask %x\n", sc->ibm_availmask);
-	device_printf(dev, "Initial Mask %x\n", sc->ibm_initialmask);
-	/* Install Specific Handler */
-	status = AcpiInstallNotifyHandler(acpi_get_handle(dev), ACPI_DEVICE_NOTIFY, acpi_ibm_notify_handler, dev);
-	SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
-			SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
-			OID_AUTO, "key_mask", CTLTYPE_INT | CTLFLAG_RW,
-			dev, 0,
-			sysctl_acpi_ibm_mask_handler, "I", "Hot key mask");
-	SYSCTL_ADD_INT(device_get_sysctl_ctx(dev),
-		       SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
-		       OID_AUTO, "version", CTLFLAG_RD,
-		       &sc->ibm_version, 0, "Interface version");
-	SYSCTL_ADD_INT(device_get_sysctl_ctx(dev),
-		       SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
-		       OID_AUTO, "avail_mask", CTLFLAG_RD,
-		       &sc->ibm_availmask, 0, "Available Key mask");
-	if (ACPI_FAILURE(acpi_SetInteger(acpi_get_handle(dev), IBM_NAME_ENABLE, 1)))
-		goto fail;
-	sc->ibm_enable = 1;
-	SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
-			SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
-			OID_AUTO, "enable", CTLTYPE_INT | CTLFLAG_RW,
-			dev, 0,
-		     sysctl_acpi_ibm_enable_handler, "I", "Hot key enable");
-	SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
-			SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
-			OID_AUTO, "misckey", CTLTYPE_INT | CTLFLAG_RD,
-			dev, 0,
-	       sysctl_acpi_ibm_misckey_handler, "I", "Key Status: Poll me");
-	SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
-			SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
-			OID_AUTO, "brightness", CTLTYPE_INT | CTLFLAG_RD,
-			dev, 0,
-		     sysctl_acpi_ibm_brightness_handler, "I", "Brightness");
-
-	SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
-			SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
-			OID_AUTO, "volume", CTLTYPE_INT | CTLFLAG_RD,
-			dev, 0,
-			sysctl_acpi_ibm_volume_handler, "I", "Volume");
-
-	SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
-			SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
-			OID_AUTO, "mute", CTLTYPE_INT | CTLFLAG_RD,
-			dev, 0,
-			sysctl_acpi_ibm_mute_handler, "I", "Muting");
-
-
-	SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
-			SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
-			OID_AUTO, "keylight", CTLTYPE_INT | CTLFLAG_RD,
-			dev, 0,
-			sysctl_acpi_ibm_keylight_handler, "I", "Key Light");
-	if (ACPI_SUCCESS(acpi_GetInteger(acpi_get_handle(dev), IBM_NAME_GET_WIRELESS, &dummy))) {
-		oid = SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
-			       SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
-		    OID_AUTO, "bluetooth", CTLTYPE_INT | CTLFLAG_RW, dev, 0,
-		 sysctl_acpi_ibm_wireless_handler, "I", "Bluetooth Enable");
-		sc->oid_bluetooth = oid;
-		oid = SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
-			       SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
-			 OID_AUTO, "wlan", CTLTYPE_INT | CTLFLAG_RW, dev, 0,
-		      sysctl_acpi_ibm_wireless_handler, "I", "WLAN Enable");
-		sc->oid_wlan = oid;
-	}
-	return_VALUE(0);
-fail:
-	device_printf(dev, "FAILED\n");
-	AcpiRemoveNotifyHandler(acpi_get_handle(dev), ACPI_DEVICE_NOTIFY, acpi_ibm_notify_handler);
-	return_VALUE(EINVAL);
+	sc->dev = dev;
+	sc->handle = acpi_get_handle(dev);
+
+	acpi_sc = acpi_device_get_parent_softc(dev);
+
+	/* Look for the first embedded controller */
+        if (!(ec_devclass = devclass_find ("acpi_ec"))) {
+		if (bootverbose)
+			device_printf(dev, "Couldn't find acpi_ec devclass\n");
+		return (EINVAL);
+	}
+        if (!(sc->ec_dev = devclass_get_device(ec_devclass, 0))) {
+		if (bootverbose)
+			device_printf(dev, "Couldn't find acpi_ec device\n");
+		return (EINVAL);
+	}
+	sc->ec_handle = acpi_get_handle(sc->ec_dev);
+
+	ACPI_SERIAL_BEGIN(ibm);
+
+	/* Get the sysctl tree */
+	sc->sysctl_ctx = device_get_sysctl_ctx(dev);
+	sc->sysctl_tree = device_get_sysctl_tree(dev);
+
+	/* Look for event mask and hook up the nodes */
+	sc->events_mask_supported = ACPI_SUCCESS(acpi_GetInteger(sc->handle,
+	    IBM_NAME_EVENTS_MASK_GET, &sc->events_initialmask));
+
+	if (sc->events_mask_supported) {
+		SYSCTL_ADD_INT(sc->sysctl_ctx,
+		    SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO,
+		    "initialmask", CTLFLAG_RD,
+		    &sc->events_initialmask, 0, "Initial eventmask");
+
+		/* The availmask is the bitmask of supported events */
+		if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
+		    IBM_NAME_EVENTS_AVAILMASK, &sc->events_availmask)))
+			sc->events_availmask = 0xffffffff;
+
+		SYSCTL_ADD_INT(sc->sysctl_ctx,
+		    SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO,
+		    "availmask", CTLFLAG_RD,
+		    &sc->events_availmask, 0, "Mask of supported events");
+	}
+
+	/* Hook up proc nodes */
+	for (int i = 0; acpi_ibm_sysctls[i].name != NULL; i++) {
+		if (!acpi_ibm_sysctl_init(sc, acpi_ibm_sysctls[i].method))
+			continue;
+
+		SYSCTL_ADD_PROC(sc->sysctl_ctx,
+		    SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO,
+		    acpi_ibm_sysctls[i].name, acpi_ibm_sysctls[i].access,
+		    sc, i, acpi_ibm_sysctl, "I",
+		    acpi_ibm_sysctls[i].description);
+	}
+
+	/* Hook up thermal node */
+	if (acpi_ibm_sysctl_init(sc, ACPI_IBM_METHOD_THERMAL)) {
+		SYSCTL_ADD_PROC(sc->sysctl_ctx,
+		    SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO,
+		    "thermal", CTLTYPE_STRING | CTLFLAG_RD,
+		    sc, 0, acpi_ibm_thermal_sysctl, "I",
+		    "Thermal zones");
+	}
+
+	ACPI_SERIAL_END(ibm);
+
+	/* Handle notifies */
+	AcpiInstallNotifyHandler(sc->handle, ACPI_DEVICE_NOTIFY,
+	    acpi_ibm_notify, dev);
+
+	/* Hook up light to led(4) */
+	sc->led_dev = led_create(ibm_led, sc, "thinklight");
+
+	return (0);
 }

 static int
@@ -259,55 +387,476 @@
 	ACPI_FUNCTION_TRACE((char *)(uintptr_t) __func__);

 	struct acpi_ibm_softc *sc = device_get_softc(dev);
-	acpi_SetInteger(acpi_get_handle(dev), IBM_NAME_ENABLE, 0);
-	acpi_ibm_enable_mask(dev, sc->ibm_initialmask);
-
-	AcpiRemoveNotifyHandler(acpi_get_handle(dev), ACPI_DEVICE_NOTIFY, acpi_ibm_notify_handler);
-	return_VALUE(0);
-}
-#if 0
+
+	/* Disable events and restore eventmask */
+	ACPI_SERIAL_BEGIN(ibm);
+	acpi_ibm_sysctl_set(sc, ACPI_IBM_METHOD_EVENTS, 0);
+	acpi_ibm_sysctl_set(sc, ACPI_IBM_METHOD_EVENTMASK, sc->events_initialmask);
+	ACPI_SERIAL_END(ibm);
+
+	AcpiRemoveNotifyHandler(sc->handle, ACPI_DEVICE_NOTIFY, acpi_ibm_notify);
+
+	led_destroy(sc->led_dev);
+	return (0);
+}
+
 static int
-acpi_ibm_suspend(device_t dev)
-{
-	struct acpi_ibm_softc *sc = device_get_softc(dev);
-	return_VALUE(0);
+acpi_ibm_eventmask_set(struct acpi_ibm_softc *sc, int val)
+{
+	ACPI_OBJECT		arg[2];
+	ACPI_OBJECT_LIST	args;
+	ACPI_STATUS		status;
+
+	ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
+	ACPI_SERIAL_ASSERT(ibm);
+
+	args.Count = 2;
+	args.Pointer = arg;
+	arg[0].Type = ACPI_TYPE_INTEGER;
+	arg[1].Type = ACPI_TYPE_INTEGER;
+
+	for (int i = 0; i < 32; ++i) {
+		arg[0].Integer.Value = i+1;
+		arg[1].Integer.Value = (((1 << i) & val) != 0);
+		status = AcpiEvaluateObject(sc->handle,
+		    IBM_NAME_EVENTS_MASK_SET, &args, NULL);
+
+		if (ACPI_FAILURE(status))
+			return (status);
+	}
+
+	return (0);
 }

 static int
-acpi_ibm_resume(device_t dev)
-{
+acpi_ibm_sysctl(SYSCTL_HANDLER_ARGS)
+{
+	struct acpi_ibm_softc	*sc;
+	int			arg;
+	int			error = 0;
+	int			function;
+	int			method;
+
+	ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
+
+	sc = (struct acpi_ibm_softc *)oidp->oid_arg1;
+	function = oidp->oid_arg2;
+	method = acpi_ibm_sysctls[function].method;
+
+	ACPI_SERIAL_BEGIN(ibm);
+	arg = acpi_ibm_sysctl_get(sc, method);
+	error = sysctl_handle_int(oidp, &arg, 0, req);
+
+	/* Sanity check */
+	if (error != 0 || req->newptr == NULL)
+		goto out;
+
+	/* Update */
+	error = acpi_ibm_sysctl_set(sc, method, arg);
+
+out:
+	ACPI_SERIAL_END(ibm);
+	return (error);
+}
+
+static int
+acpi_ibm_sysctl_get(struct acpi_ibm_softc *sc, int method)
+{
+	ACPI_INTEGER	val_ec;
+	int 		val = 0, key;
+
+	ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
+	ACPI_SERIAL_ASSERT(ibm);
+
+	switch (method) {
+	case ACPI_IBM_METHOD_EVENTS:
+		acpi_GetInteger(sc->handle, IBM_NAME_EVENTS_STATUS_GET, &val);
+		break;
+
+	case ACPI_IBM_METHOD_EVENTMASK:
+		if (sc->events_mask_supported)
+			acpi_GetInteger(sc->handle, IBM_NAME_EVENTS_MASK_GET, &val);
+		break;
+
+	case ACPI_IBM_METHOD_HOTKEY:
+		/*
+		 * Construct the hotkey as a bitmask as illustrated below.
+		 * Note that whenever a key was pressed, the respecting bit
+		 * toggles and nothing else changes.
+		 * +--+--+-+-+-+-+-+-+-+-+-+-+
+		 * |11|10|9|8|7|6|5|4|3|2|1|0|
+		 * +--+--+-+-+-+-+-+-+-+-+-+-+
+		 *   |  | | | | | | | | | | |
+		 *   |  | | | | | | | | | | +- Home Button
+		 *   |  | | | | | | | | | +--- Search Button
+		 *   |  | | | | | | | | +----- Mail Button
+		 *   |  | | | | | | | +------- Thinkpad Button
+		 *   |  | | | | | | +--------- Zoom (Fn + Space)
+		 *   |  | | | | | +----------- WLAN Button
+		 *   |  | | | | +------------- Video Button
+		 *   |  | | | +--------------- Hibernate Button
+		 *   |  | | +----------------- Thinklight Button
+		 *   |  | +------------------- Screen expand (Fn + F8)
+		 *   |  +--------------------- Brightness
+		 *   +------------------------ Volume/Mute
+		 */
+		key = rtcin(IBM_RTC_HOTKEY1);
+		val = (IBM_RTC_MASK_HOME | IBM_RTC_MASK_SEARCH | IBM_RTC_MASK_MAIL | IBM_RTC_MASK_WLAN) & key;
+		key = rtcin(IBM_RTC_HOTKEY2);
+		val |= (IBM_RTC_MASK_THINKPAD | IBM_RTC_MASK_VIDEO | IBM_RTC_MASK_HIBERNATE) & key;
+		val |= (IBM_RTC_MASK_ZOOM & key) >> 1;
+		key = rtcin(IBM_RTC_THINKLIGHT);
+		val |= (IBM_RTC_MASK_THINKLIGHT & key) << 4;
+		key = rtcin(IBM_RTC_SCREENEXPAND);
+		val |= (IBM_RTC_MASK_THINKLIGHT & key) << 4;
+		key = rtcin(IBM_RTC_BRIGHTNESS);
+		val |= (IBM_RTC_MASK_BRIGHTNESS & key) << 5;
+		key = rtcin(IBM_RTC_VOLUME);
+		val |= (IBM_RTC_MASK_VOLUME & key) << 4;
+		break;
+
+	case ACPI_IBM_METHOD_BRIGHTNESS:
+		ACPI_EC_READ(sc->ec_dev, IBM_EC_BRIGHTNESS, &val_ec, 1);
+		val = val_ec & IBM_EC_MASK_BRI;
+		break;
+
+	case ACPI_IBM_METHOD_VOLUME:
+		ACPI_EC_READ(sc->ec_dev, IBM_EC_VOLUME, &val_ec, 1);
+		val = val_ec &IBM_EC_MASK_VOL;
+		break;
+
+	case ACPI_IBM_METHOD_MUTE:
+		ACPI_EC_READ(sc->ec_dev, IBM_EC_VOLUME, &val_ec, 1);
+		val = ((val_ec & IBM_EC_MASK_MUTE) == IBM_EC_MASK_MUTE);
+		break;
+
+	case ACPI_IBM_METHOD_THINKLIGHT:
+		if (sc->light_get_supported)
+			acpi_GetInteger(sc->ec_handle, IBM_NAME_KEYLIGHT, &val);
+		else
+			val = sc->light_val;
+		break;
+
+	case ACPI_IBM_METHOD_BLUETOOTH:
+		acpi_GetInteger(sc->handle, IBM_NAME_WLAN_BT_GET, &val);
+		sc->wlan_bt_flags = val;
+		val = ((val & IBM_NAME_MASK_BT) != 0);
+		break;
+
+	case ACPI_IBM_METHOD_WLAN:
+		acpi_GetInteger(sc->handle, IBM_NAME_WLAN_BT_GET, &val);
+		sc->wlan_bt_flags = val;
+		val = ((val & IBM_NAME_MASK_WLAN) != 0);
+		break;
+
+	case ACPI_IBM_METHOD_FANSPEED:
+		if (sc->fan_handle) {
+			if(ACPI_FAILURE(acpi_GetInteger(sc->fan_handle, NULL, &val)))
+				val = -1;
+		}
+		else {
+			ACPI_EC_READ(sc->ec_dev, IBM_EC_FANSPEED, &val_ec, 2);
+			val = val_ec;
+		}
+		break;
+
+	case ACPI_IBM_METHOD_FANSTATUS:
+		if (!sc->fan_handle) {
+			ACPI_EC_READ(sc->ec_dev, IBM_EC_FANSTATUS, &val_ec, 1);
+			val = (val_ec & IBM_EC_MASK_FANSTATUS) == IBM_EC_MASK_FANSTATUS;
+		}
+		else
+			val = -1;
+		break;
+	}
+
+	return (val);
+}
+
+static int
+acpi_ibm_sysctl_set(struct acpi_ibm_softc *sc, int method, int arg)
+{
+	int			val, step;
+	ACPI_INTEGER		val_ec;
+	ACPI_OBJECT		Arg;
+	ACPI_OBJECT_LIST	Args;
+	ACPI_STATUS		status;
+
+	ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
+	ACPI_SERIAL_ASSERT(ibm);
+
+	switch (method) {
+	case ACPI_IBM_METHOD_EVENTS:
+		if (arg < 0 || arg > 1)
+			return (EINVAL);
+
+		status = acpi_SetInteger(sc->handle, IBM_NAME_EVENTS_STATUS_SET, arg);
+		if (ACPI_FAILURE(status))
+			return (status);
+		if (sc->events_mask_supported)
+			return acpi_ibm_eventmask_set(sc, sc->events_availmask);
+		break;
+
+	case ACPI_IBM_METHOD_EVENTMASK:
+		if (sc->events_mask_supported)
+			return acpi_ibm_eventmask_set(sc, arg);
+		break;
+
+	case ACPI_IBM_METHOD_BRIGHTNESS:
+		if (arg < 0 || arg > 7)
+			return (EINVAL);
+
+		if (sc->cmos_handle) {
+			/* Read the current brightness */
+			status = ACPI_EC_READ(sc->ec_dev, IBM_EC_BRIGHTNESS, &val_ec, 1);
+			if (ACPI_FAILURE(status))
+				return (status);
+			val = val_ec & IBM_EC_MASK_BRI;
+
+			Args.Count = 1;
+			Args.Pointer = &Arg;
+			Arg.Type = ACPI_TYPE_INTEGER;
+			Arg.Integer.Value = (arg > val) ? IBM_CMOS_BRIGHTNESS_UP : IBM_CMOS_BRIGHTNESS_DOWN;
+
+			step = (arg > val) ? 1 : -1;
+			for (int i = val; i != arg; i += step) {
+				status = AcpiEvaluateObject(sc->cmos_handle, NULL, &Args, NULL);
+				if (ACPI_FAILURE(status))
+					break;
+			}
+		}
+		return ACPI_EC_WRITE(sc->ec_dev, IBM_EC_BRIGHTNESS, arg, 1);
+		break;
+
+	case ACPI_IBM_METHOD_VOLUME:
+		if (arg < 0 || arg > 14)
+			return (EINVAL);
+
+		if (sc->cmos_handle) {
+			status = ACPI_EC_READ(sc->ec_dev, IBM_EC_VOLUME, &val_ec, 1);
+			if (ACPI_FAILURE(status))
+				return (status);
+			val = val_ec & IBM_EC_MASK_VOL;
+
+			Args.Count = 1;
+			Args.Pointer = &Arg;
+			Arg.Type = ACPI_TYPE_INTEGER;
+			Arg.Integer.Value = (arg > val) ? IBM_CMOS_VOLUME_UP : IBM_CMOS_VOLUME_DOWN;
+
+			step = (arg > val) ? 1 : -1;
+			for (int i = val; i != arg; i += step) {
+				status = AcpiEvaluateObject(sc->cmos_handle, NULL, &Args, NULL);
+				if (ACPI_FAILURE(status))
+					break;
+			}
+		}
+		return ACPI_EC_WRITE(sc->ec_dev, IBM_EC_VOLUME, arg + (val_ec & (~IBM_EC_MASK_VOL)), 1);
+		break;
+
+	case ACPI_IBM_METHOD_MUTE:
+		if (arg < 0 || arg > 1)
+			return (EINVAL);
+
+		if (sc->cmos_handle) {
+			status = ACPI_EC_READ(sc->ec_dev, IBM_EC_VOLUME, &val_ec, 1);
+			if (ACPI_FAILURE(status))
+				return (status);
+			val = val_ec & IBM_EC_MASK_VOL;
+
+			Args.Count = 1;
+			Args.Pointer = &Arg;
+			Arg.Type = ACPI_TYPE_INTEGER;
+			Arg.Integer.Value = IBM_CMOS_VOLUME_MUTE;
+
+			status = AcpiEvaluateObject(sc->cmos_handle, NULL, &Args, NULL);
+			if (ACPI_FAILURE(status))
+				break;
+		}
+		return ACPI_EC_WRITE(sc->ec_dev, IBM_EC_VOLUME, (arg==1) ? val_ec | IBM_EC_MASK_MUTE : val_ec & (~IBM_EC_MASK_MUTE), 1);
+		break;
+
+	case ACPI_IBM_METHOD_THINKLIGHT:
+		if (arg < 0 || arg > 1)
+			return (EINVAL);
+
+		if (sc->light_set_supported) {
+			Args.Count = 1;
+			Args.Pointer = &Arg;
+			Arg.Type = ACPI_TYPE_INTEGER;
+			Arg.Integer.Value = arg ? sc->light_cmd_on : sc->light_cmd_off;
+
+			status = AcpiEvaluateObject(sc->light_handle, NULL, &Args, NULL);
+			if (ACPI_SUCCESS(status))
+				sc->light_val = arg;
+			return (status);
+		}
+		break;
+
+	case ACPI_IBM_METHOD_BLUETOOTH:
+		if (arg < 0 || arg > 1)
+			return (EINVAL);
+
+		val = (arg == 1) ? sc->wlan_bt_flags | IBM_NAME_MASK_BT : sc->wlan_bt_flags & (~IBM_NAME_MASK_BT);
+		return acpi_SetInteger(sc->handle, IBM_NAME_WLAN_BT_SET, val);
+		break;
+	}
+
 	return (0);
 }
-#endif
+
+static int
+acpi_ibm_sysctl_init(struct acpi_ibm_softc *sc, int method)
+{
+	int 			dummy;
+	ACPI_OBJECT_TYPE 	cmos_t;
+	ACPI_HANDLE		ledb_handle;
+
+	switch (method) {
+	case ACPI_IBM_METHOD_EVENTS:
+		/* Events are disabled by default */
+		return (TRUE);
+
+	case ACPI_IBM_METHOD_EVENTMASK:
+		return (sc->events_mask_supported);
+
+	case ACPI_IBM_METHOD_HOTKEY:
+	case ACPI_IBM_METHOD_BRIGHTNESS:
+	case ACPI_IBM_METHOD_VOLUME:
+	case ACPI_IBM_METHOD_MUTE:
+		/* EC is required here, which was aready checked before */
+		return (TRUE);
+
+	case ACPI_IBM_METHOD_THINKLIGHT:
+		sc->cmos_handle = NULL;
+		sc->light_get_supported = ACPI_SUCCESS(acpi_GetInteger(sc->ec_handle, IBM_NAME_KEYLIGHT, &dummy));
+
+		if ((ACPI_SUCCESS(AcpiGetHandle(sc->handle, "\\UCMS", &sc->light_handle)) ||
+		     ACPI_SUCCESS(AcpiGetHandle(sc->handle, "\\CMOS", &sc->light_handle)) ||
+		     ACPI_SUCCESS(AcpiGetHandle(sc->handle, "\\CMS", &sc->light_handle))) &&
+		     ACPI_SUCCESS(AcpiGetType(sc->light_handle, &cmos_t)) &&
+		     cmos_t == ACPI_TYPE_METHOD) {
+			sc->light_cmd_on = 0x0c;
+			sc->light_cmd_off = 0x0d;
+			sc->cmos_handle = sc->light_handle;
+		}
+		else if (ACPI_SUCCESS(AcpiGetHandle(sc->handle, "\\LGHT", &sc->light_handle))) {
+			sc->light_cmd_on = 1;
+			sc->light_cmd_off = 0;
+		}
+		else
+			sc->light_handle = NULL;
+
+		sc->light_set_supported = (sc->light_handle &&
+		    ACPI_FAILURE(AcpiGetHandle(sc->ec_handle, "LEDB", &ledb_handle)));
+
+		if (sc->light_get_supported || sc->light_set_supported) {
+			sc->light_val = 0;
+			return (TRUE);
+		}
+		else
+			return (FALSE);
+
+	case ACPI_IBM_METHOD_BLUETOOTH:
+	case ACPI_IBM_METHOD_WLAN:
+		if (ACPI_SUCCESS(acpi_GetInteger(sc->handle, IBM_NAME_WLAN_BT_GET, &dummy)))
+			return (TRUE);
+		return (FALSE);
+
+	case ACPI_IBM_METHOD_FANSPEED:
+		/*
+		 * Some models report the fan speed in levels from 0-7
+		 * Newer models report it contiguously
+		 */
+		sc->fan_levels =
+		    (ACPI_SUCCESS(AcpiGetHandle(sc->handle, "GFAN", &sc->fan_handle)) ||
+		     ACPI_SUCCESS(AcpiGetHandle(sc->handle, "\\FSPD", &sc->fan_handle)));
+		return (TRUE);
+
+	case ACPI_IBM_METHOD_FANSTATUS:
+		/*
+		 * Fan status is only supported on those models,
+		 * which report fan RPM contiguously, not in levels
+		 */
+		if (sc->fan_levels)
+			return (FALSE);
+		return (TRUE);
+
+	case ACPI_IBM_METHOD_THERMAL:
+		if (ACPI_SUCCESS(acpi_GetInteger(sc->ec_handle, IBM_NAME_THERMAL_GET, &dummy))) {
+			sc->thermal_updt_supported = ACPI_SUCCESS(acpi_GetInteger(sc->ec_handle, IBM_NAME_THERMAL_UPDT, &dummy));
+			return (TRUE);
+		}
+		return (FALSE);
+	}
+	return (FALSE);
+}
+
+static int
+acpi_ibm_thermal_sysctl(SYSCTL_HANDLER_ARGS)
+{
+	struct acpi_ibm_softc	*sc;
+	int			error = 0;
+	char			temp_cmd[] = "TMP0";
+	int			temp[8];
+
+	ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
+
+	sc = (struct acpi_ibm_softc *)oidp->oid_arg1;
+
+	ACPI_SERIAL_BEGIN(ibm);
+
+	for (int i = 0; i < 8; ++i) {
+		temp_cmd[3] = '0' + i;
+
+		/*
+		 * The TMPx methods seem to return +/- 128 or 0
+		 * when the respecting sensor is not available
+		 */
+		if (ACPI_FAILURE(acpi_GetInteger(sc->ec_handle, temp_cmd,
+		    &temp[i])) || ABS(temp[i]) == 128 || temp[i] == 0)
+			temp[i] = -1;
+		else if (sc->thermal_updt_supported)
+			/* Temperature is reported in tenth of Kelvin */
+			temp[i] = (temp[i] - 2732 + 5) / 10;
+	}
+
+	error = sysctl_handle_opaque(oidp, &temp, 8*sizeof(int), req);
+
+	ACPI_SERIAL_END(ibm);
+	return (error);
+}
+
 static void
-acpi_ibm_notify_handler(ACPI_HANDLE h, UINT32 notify,
-			void *context)
-{
-	int		mhkp      , arg, type;
+acpi_ibm_notify(ACPI_HANDLE h, UINT32 notify, void *context)
+{
+	int		event, arg, type;
 	device_t	dev = context;
 	struct acpi_ibm_softc *sc = device_get_softc(dev);

+	ACPI_FUNCTION_TRACE_U32((char *)(uintptr_t)__func__, notify);
+
 	printf("IBM:NOTIFY:%x\n", notify);
-	if (notify != 0x80) {
+	if (notify != 0x80)
 		printf("Unknown notify\n");
-	}
+
 	for (;;) {
-
-		acpi_GetInteger(acpi_get_handle(dev), IBM_NAME_GET_EVENT, &mhkp);
-
-		if (mhkp == 0) {
+		acpi_GetInteger(acpi_get_handle(dev), IBM_NAME_EVENTS_GET, &event);
+
+		if (event == 0)
 			break;
-		}
-		printf("notify:%x\n", mhkp);
-
-		type = (mhkp >> 12) & 0xf;
-		arg = mhkp & 0xfff;
+
+		printf("notify:%x\n", event);
+
+		type = (event >> 12) & 0xf;
+		arg = event & 0xfff;
 		switch (type) {
 		case 1:
-			if (!(sc->ibm_availmask & (1 << (arg - 1)))) {
+			if (!(sc->events_availmask & (1 << (arg - 1)))) {
 				printf("Unknown key %d\n", arg);
 				break;
 			}
+
+			/* Notify devd(8) */
 			acpi_UserNotify("IBM", h, (arg & 0xff));
 			break;
 		default:
@@ -315,158 +864,3 @@
 		}
 	}
 }
-
-static int
-acpi_ibm_enable_mask(device_t dev, int val)
-{
-	int		i;
-	struct acpi_ibm_softc *sc = device_get_softc(dev);
-
-	if (!(sc->device_flag | IBM_MHKM_AVAIL)) {
-		return -1;
-	}
-	for (i = 0; i < 32; i++) {
-		acpi_ibm_call_two_method(dev, IBM_NAME_MODIFY_MASK, i + 1, 1);
-		if (!((1 << i) & val))
-			acpi_ibm_call_two_method(dev, IBM_NAME_MODIFY_MASK, i + 1, 0);
-	}
-	return 0;
-}
-
-static int
-sysctl_acpi_ibm_mask_handler(SYSCTL_HANDLER_ARGS)
-{
-	device_t	dev = arg1;
-	int		val = 0xffffffff;
-	int		error = 0;
-
-	struct acpi_ibm_softc *sc = device_get_softc(dev);
-
-	if (sc->device_flag & IBM_MHKN_AVAIL)
-		acpi_GetInteger(acpi_get_handle(dev), IBM_NAME_CURRENT_MASK, &val);
-
-	error = sysctl_handle_int(oidp, &val, 0, req);
-
-	if (error || !req->newptr)
-		return error;
-
-	val &= sc->ibm_availmask;
-	val |= sc->ibm_initialmask;
-
-	acpi_ibm_enable_mask(dev, val);
-
-	return 0;
-}
-
-static int
-sysctl_acpi_ibm_misckey_handler(SYSCTL_HANDLER_ARGS)
-{
-	int		val       , error;
-	val = rtcin(IBM_RTC_MISCKEY);
-	error = sysctl_handle_int(oidp, &val, 0, req);
-	if (error || !req->newptr)
-		return error;
-	return 0;
-}
-
-
-static int
-sysctl_acpi_ibm_brightness_handler(SYSCTL_HANDLER_ARGS)
-{
-	int		val       , error;
-	val = rtcin(IBM_RTC_BRIGHTNESS);
-	val &= IBM_RTC_MASK_BRI;
-	error = sysctl_handle_int(oidp, &val, 0, req);
-	if (error || !req->newptr)
-		return error;
-	return 0;
-}
-
-static int
-sysctl_acpi_ibm_mute_handler(SYSCTL_HANDLER_ARGS)
-{
-	int		val       , error;
-	val = rtcin(IBM_RTC_VOLUME);
-	val = ((val & IBM_RTC_MASK_MUTE) == IBM_RTC_MASK_MUTE);
-
-	error = sysctl_handle_int(oidp, &val, 0, req);
-	if (error || !req->newptr)
-		return error;
-	return 0;
-}
-
-static int
-sysctl_acpi_ibm_keylight_handler(SYSCTL_HANDLER_ARGS)
-{
-	int		val       , error;
-	val = ((rtcin(IBM_RTC_KEYLIGHT) & IBM_RTC_MASK_KEYLIGHT)
-	       == IBM_RTC_MASK_KEYLIGHT);
-
-	error = sysctl_handle_int(oidp, &val, 0, req);
-	if (error || !req->newptr)
-		return error;
-	return 0;
-}
-
-static int
-sysctl_acpi_ibm_volume_handler(SYSCTL_HANDLER_ARGS)
-{
-	int		val       , error;
-	val = rtcin(IBM_RTC_VOLUME);
-	val &= IBM_RTC_MASK_VOL;
-	error = sysctl_handle_int(oidp, &val, 0, req);
-	if (error || !req->newptr)
-		return error;
-	return 0;
-}
-
-static int
-sysctl_acpi_ibm_enable_handler(SYSCTL_HANDLER_ARGS)
-{
-	device_t	dev = arg1;
-	struct acpi_ibm_softc *sc = device_get_softc(dev);
-	int		error = 0;
-
-	error = sysctl_handle_int(oidp, &sc->ibm_enable, 0, req);
-
-	if (error || !req->newptr)
-		return error;
-
-	if (sc->ibm_enable)
-		sc->ibm_enable = 1;
-	else
-		sc->ibm_enable = 0;
-	acpi_SetInteger(acpi_get_handle(dev), IBM_NAME_ENABLE, sc->ibm_enable);
-
-	return 0;
-}
-
-static int
-sysctl_acpi_ibm_wireless_handler(SYSCTL_HANDLER_ARGS)
-{
-	device_t	dev = arg1;
-	struct acpi_ibm_softc *sc = device_get_softc(dev);
-	int		error = 0,	val, oldval, mask;
-	if (sc->oid_bluetooth == oidp) {
-		mask = 2;
-	} else if (sc->oid_wlan == oidp) {
-		mask = 4;
-	} else {
-		printf("WARNING: wrong handler invoked\n");
-		return ENOENT;
-	}
-
-	acpi_GetInteger(acpi_get_handle(dev), IBM_NAME_GET_WIRELESS, &oldval);
-	val = !((oldval & mask) == 0);
-	error = sysctl_handle_int(oidp, &val, 0, req);
-
-	if (error || !req->newptr)
-		return error;
-	oldval &= (~mask);
-	if (val)
-		oldval |= mask;
-	acpi_SetInteger(acpi_get_handle(dev), IBM_NAME_SET_WIRELESS, oldval);
-	return 0;
-
-
-}


BT - incremented version

BT - incremented version

--- src/batterytech/src/batterytech/batterytech_globals.h
+++ src/batterytech/src/batterytech/batterytech_globals.h
@@ -76,6 +76,6 @@
 #define FORCE_16_BIT_RGB_TEXTURES FALSE

 /// ------------- version ---------------
-#define BATTERYTECH_VERSION "2.0.0"
+#define BATTERYTECH_VERSION "2.0.2"

 #endif /* BATTERYTECH_GLOBALS_H_ */


MeshTools: fix warnings in build with CORRADE_NO_ASSERT.

--- src/Magnum/MeshTools/Interleave.h
+++ src/Magnum/MeshTools/Interleave.h
@@ -46,6 +46,9 @@
 struct AttributeCount {
     template<class T, class ...U> typename std::enable_if<!std::is_convertible<T, std::size_t>::value, std::size_t>::type operator()(const T& first, const U&... next) const {
         CORRADE_ASSERT(sizeof...(next) == 0 || AttributeCount{}(next...) == first.size() || AttributeCount{}(next...) == ~std::size_t(0), "MeshTools::interleave(): attribute arrays don't have the same length, expected" << first.size() << "but got" << AttributeCount{}(next...), 0);
+        #if defined(CORRADE_NO_ASSERT) && !defined(CORRADE_GRACEFUL_ASSERT)
+        static_cast<void>(sizeof...(next));
+        #endif

         return first.size();
     }
@@ -163,10 +166,12 @@
     contain the interleaved data.
 */
 template<class T, class ...U> void interleaveInto(Containers::ArrayView<char> buffer, const T& first, const U&... next) {
+    #if !defined(CORRADE_NO_ASSERT) || defined(CORRADE_GRACEFUL_ASSERT)
     /* Verify expected buffer size */
     const std::size_t attributeCount = Implementation::AttributeCount{}(first, next...);
     const std::size_t stride = Implementation::Stride{}(first, next...);
     CORRADE_ASSERT(attributeCount*stride <= buffer.size(), "MeshTools::interleaveInto(): the data buffer is too small, expected" << attributeCount*stride << "but got" << buffer.size(), );
+    #endif

     /* Write data */
     Implementation::writeInterleaved(stride, buffer.begin(), first, next...);


monitor: better debug names

monitor: better debug names

--- sys/dev/netmap/netmap_monitor.c
+++ sys/dev/netmap/netmap_monitor.c
@@ -641,6 +641,7 @@
 	int i, error;
 	enum txrx t;
 	int zcopy = (nmr->nr_flags & NR_ZCOPY_MON);
+	char monsuff[10] = "";

 	if ((nmr->nr_flags & (NR_MONITOR_TX | NR_MONITOR_RX)) == 0) {
 		ND("not a monitor");
@@ -687,7 +688,14 @@
 		D("ringid error");
 		goto put_out;
 	}
-	snprintf(mna->up.name, sizeof(mna->up.name), "mon:%s", pna->name);
+	if (mna->priv.np_qlast[NR_TX] - mna->priv.np_qfirst[NR_TX] == 1) {
+		snprintf(monsuff, 10, "-%d", mna->priv.np_qfirst[NR_TX]);
+	}
+	snprintf(mna->up.name, sizeof(mna->up.name), "%s%s/%s%s%s", pna->name,
+			monsuff,
+			zcopy ? "z" : "",
+			(nmr->nr_flags & NR_MONITOR_RX) ? "r" : "",
+			(nmr->nr_flags & NR_MONITOR_TX) ? "t" : "");

 	if (zcopy) {
 		/* zero copy monitors need exclusive access to the monitored rings */


Temporarily disable shared Mbed TLS heap for SGM

There is a bug in the shared heap implementation for SGM. Until the bug
is solved, the default implementation is used.

Change-Id: I010911a3f00ed860f742b14daad1d99b9e7ce711
Signed-off-by: John Tsichritzis <c5e6a94b5ed6b01ab911c6a4e005fdf814669fe4@arm.com>

--- plat/arm/css/sgm/sgm_plat_config.c
+++ plat/arm/css/sgm/sgm_plat_config.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -10,6 +10,7 @@
 #include <platform_def.h>

 #include <common/debug.h>
+#include <plat/common/platform.h>
 #include <plat/arm/common/plat_arm.h>

 #include <sgm_plat_config.h>
@@ -74,9 +75,6 @@
 #if TRUSTED_BOARD_BOOT
 int plat_get_mbedtls_heap(void **heap_addr, size_t *heap_size)
 {
-	assert(heap_addr != NULL);
-	assert(heap_size != NULL);
-
-	return arm_get_mbedtls_heap(heap_addr, heap_size);
+	return get_mbedtls_heap_helper(heap_addr, heap_size);
 }
 #endif


parse-events: Add support for printing short fields

Handle "%hd" etc. in pretty_print()

Signed-off-by: David Sharp <d17c0a8430b0bd65a7a6ae309f7a3dc190d92668@google.com>
LKML-Reference: <1299715137-22768-1-git-send-email-d17c0a8430b0bd65a7a6ae309f7a3dc190d92668@google.com>
Google-Bug-Id: 3501052
Signed-off-by: Steven Rostedt <43232e92d70cc7aa53504ad0397085ee47bad87f@goodmis.org>


Removed uneeded printf

Removed uneeded printf

--- test_netprot_header.c
+++ test_netprot_header.c
@@ -117,8 +117,6 @@
 	header_size_ptr = getoffsetptr(*header, 1);
 	header_size = extract_uint8(header_size_ptr);

-	printf("header_size: %d \n", header_size);
-
 	/* Check data is valid */
 	data_ptr = getoffsetptr(*header, header_size);
 	err = strncmp(data_ptr, data, datasize);


Add error case during symbol analysis for types


Add missing export macro for Box class

Add missing export macro for Box class

--- src/Mod/Part/App/FeaturePartBox.h
+++ src/Mod/Part/App/FeaturePartBox.h
@@ -32,7 +32,7 @@
 namespace Part
 {

-class Box :public Part::Primitive
+class PartExport Box :public Part::Primitive
 {
     PROPERTY_HEADER(Part::Box);


[SEAP] use non-blocking locking in __seap_debug_log

--- src/OVAL/probes/SEAP/seap-debug.c
+++ src/OVAL/probes/SEAP/seap-debug.c
@@ -53,7 +53,7 @@
                 fprintf (__debuglog_fp, "=============== LOG: %.24s ===============\n", st);
         }

-        if (flock (fileno (__debuglog_fp), LOCK_EX) == -1) {
+        if (flock (fileno (__debuglog_fp), LOCK_EX | LOCK_NB) == -1) {
                 __UNLOCK_FP;
                 return;
         }
@@ -68,7 +68,7 @@
         vfprintf (__debuglog_fp, fmt, ap);
         va_end (ap);

-        if (flock (fileno (__debuglog_fp), LOCK_UN) == -1) {
+        if (flock (fileno (__debuglog_fp), LOCK_UN | LOCK_NB) == -1) {
                 /* __UNLOCK_FP; */
                 abort ();
         }