3 ==================================================================================
4 Copyright (c) 2019 Nokia
5 Copyright (c) 2018-2019 AT&T Intellectual Property.
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18 ==================================================================================
22 Mnemonic: mt_call_static.c
23 Abstract: Static multi-threaded call support.
25 Author: E. Scott Daniels
29 #ifndef mtcall_static_c
30 #define mtcall_static_c
39 #include <sys/types.h>
45 #include <semaphore.h>
49 Initialises the chutes that are then hung off of the context.
51 Returns > 0 on success; 0 on failure with errno set.
53 static int init_mtcall( uta_ctx_t* ctx ) {
54 int rc = 1; // return code 1== good.
63 chutes = ctx->chutes = (chute_t *) malloc( sizeof( chute_t ) * (MAX_CALL_ID+1) );
64 if( chutes == NULL ) {
68 for( i = 0; i < MAX_CALL_ID; i++ ) { // initialise all of the semaphores
69 chutes[i].mbuf = NULL;
70 if( sem_init( &chutes[i].barrier, 0, 0 ) < 0 ) {
71 fprintf( stderr, "[ERR] rmr: unable to initialise mt call chute [%d]: %s\n", i, strerror( errno ) );