2 * Copyright (c) 2016 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
15 #ifndef __included_jvpp_common_h__
16 #define __included_jvpp_common_h__
18 #include <vppinfra/types.h>
19 #include <vlibapi/api.h>
20 #include <vlibmemory/api.h>
24 /* Unique identifier used for matching replays with requests */
25 volatile u32 context_id;
31 /* JNI Native Method Interface pointer for message handlers */
34 /* JNI Invoke Interface pointer for attachment of rx thread to java thread */
38 unix_shared_memory_queue_t * vl_input_queue;
42 extern jvpp_main_t jvpp_main __attribute__((aligned (64)));
44 static_always_inline u32 vppjni_get_context_id(jvpp_main_t * jm) {
45 return __sync_add_and_fetch(&jm->context_id, 1);
48 static_always_inline void vppjni_lock(jvpp_main_t * jm, u32 tag) {
49 while (__sync_lock_test_and_set(&jm->lock, 1))
54 static_always_inline void vppjni_unlock(jvpp_main_t * jm) {
56 CLIB_MEMORY_BARRIER();
61 * Calls onError callback on callbackObject reference. Passes instance of callbackExceptionClass as parameter.
63 void call_on_error(const char* callName, int contextId, int retval,
64 jclass callbackClass, jobject callbackObject,
65 jclass callbackExceptionClass);
67 #endif /* __included_jvpp_common_h__ */