|
Packit |
352660 |
/*
|
|
Packit |
352660 |
* fontconfig/test/test-pthread.c
|
|
Packit |
352660 |
*
|
|
Packit |
352660 |
* Copyright © 2000 Keith Packard
|
|
Packit |
352660 |
* Copyright © 2013 Raimund Steger
|
|
Packit |
352660 |
*
|
|
Packit |
352660 |
* Permission to use, copy, modify, distribute, and sell this software and its
|
|
Packit |
352660 |
* documentation for any purpose is hereby granted without fee, provided that
|
|
Packit |
352660 |
* the above copyright notice appear in all copies and that both that
|
|
Packit |
352660 |
* copyright notice and this permission notice appear in supporting
|
|
Packit |
352660 |
* documentation, and that the name of the author(s) not be used in
|
|
Packit |
352660 |
* advertising or publicity pertaining to distribution of the software without
|
|
Packit |
352660 |
* specific, written prior permission. The authors make no
|
|
Packit |
352660 |
* representations about the suitability of this software for any purpose. It
|
|
Packit |
352660 |
* is provided "as is" without express or implied warranty.
|
|
Packit |
352660 |
*
|
|
Packit |
352660 |
* THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
Packit |
352660 |
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
|
Packit |
352660 |
* EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
|
Packit |
352660 |
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
Packit |
352660 |
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
Packit |
352660 |
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
Packit |
352660 |
* PERFORMANCE OF THIS SOFTWARE.
|
|
Packit |
352660 |
*/
|
|
Packit |
352660 |
#include <stdio.h>
|
|
Packit |
352660 |
#include <stdlib.h>
|
|
Packit |
352660 |
#include <unistd.h>
|
|
Packit |
352660 |
#include <pthread.h>
|
|
Packit |
352660 |
#include <fontconfig/fontconfig.h>
|
|
Packit |
352660 |
|
|
Packit |
352660 |
#define NTHR 100
|
|
Packit |
352660 |
#define NTEST 100
|
|
Packit |
352660 |
|
|
Packit |
352660 |
struct thr_arg_s
|
|
Packit |
352660 |
{
|
|
Packit |
352660 |
int thr_num;
|
|
Packit |
352660 |
};
|
|
Packit |
352660 |
|
|
Packit |
352660 |
static void test_match(int thr_num,int test_num)
|
|
Packit |
352660 |
{
|
|
Packit |
352660 |
FcPattern *pat;
|
|
Packit |
352660 |
FcPattern *match;
|
|
Packit |
352660 |
FcResult result;
|
|
Packit |
352660 |
|
|
Packit |
352660 |
FcInit();
|
|
Packit |
352660 |
|
|
Packit |
352660 |
pat = FcNameParse((const FcChar8 *)"New Century Schoolbook");
|
|
Packit |
352660 |
|
|
Packit |
352660 |
FcConfigSubstitute(0,pat,FcMatchPattern);
|
|
Packit |
352660 |
FcDefaultSubstitute(pat);
|
|
Packit |
352660 |
|
|
Packit |
352660 |
match = FcFontMatch(0,pat,&result);
|
|
Packit |
352660 |
|
|
Packit |
352660 |
FcPatternDestroy(pat);
|
|
Packit |
352660 |
FcPatternDestroy(match);
|
|
Packit |
352660 |
}
|
|
Packit |
352660 |
|
|
Packit |
352660 |
static void *run_test_in_thread(void *arg)
|
|
Packit |
352660 |
{
|
|
Packit |
352660 |
struct thr_arg_s *thr_arg=(struct thr_arg_s *)arg;
|
|
Packit |
352660 |
int thread_num = thr_arg->thr_num;
|
|
Packit |
352660 |
int i=0;
|
|
Packit |
352660 |
|
|
Packit |
352660 |
for(;i
|
|
Packit |
352660 |
|
|
Packit |
352660 |
printf("Thread %d: done\n",thread_num);
|
|
Packit |
352660 |
|
|
Packit |
352660 |
return NULL;
|
|
Packit |
352660 |
}
|
|
Packit |
352660 |
|
|
Packit |
352660 |
int main(int argc,char **argv)
|
|
Packit |
352660 |
{
|
|
Packit |
352660 |
pthread_t threads[NTHR];
|
|
Packit |
352660 |
int i, j;
|
|
Packit |
352660 |
|
|
Packit |
352660 |
printf("Creating %d threads\n",NTHR);
|
|
Packit |
352660 |
|
|
Packit |
352660 |
for(i = 0;i
|
|
Packit |
352660 |
{
|
|
Packit |
352660 |
struct thr_arg_s thr_arg;
|
|
Packit |
352660 |
int result;
|
|
Packit |
352660 |
thr_arg.thr_num=i;
|
|
Packit |
352660 |
result = pthread_create(&threads[i],NULL,run_test_in_thread,
|
|
Packit |
352660 |
(void *)&thr_arg);
|
|
Packit |
352660 |
if(result!=0)
|
|
Packit |
352660 |
{
|
|
Packit |
352660 |
fprintf(stderr,"Cannot create thread %d\n",i);
|
|
Packit |
352660 |
break;
|
|
Packit |
352660 |
}
|
|
Packit |
352660 |
}
|
|
Packit |
352660 |
|
|
Packit |
352660 |
for(j=0;j
|
|
Packit |
352660 |
{
|
|
Packit |
352660 |
pthread_join(threads[j],NULL);
|
|
Packit |
352660 |
printf("Joined thread %d\n",j);
|
|
Packit |
352660 |
}
|
|
Packit |
352660 |
|
|
Packit |
352660 |
FcFini();
|
|
Packit |
352660 |
|
|
Packit |
352660 |
return 0;
|
|
Packit |
352660 |
}
|