19303f819SKyle Evans /*
29303f819SKyle Evans * SPDX-License-Identifier: BSD-2-Clause
39303f819SKyle Evans *
49303f819SKyle Evans * Copyright (C) 2019 Andrew Gierth
59303f819SKyle Evans *
69303f819SKyle Evans * Redistribution and use in source and binary forms, with or without
79303f819SKyle Evans * modification, are permitted provided that the following conditions
89303f819SKyle Evans * are met:
99303f819SKyle Evans * 1. Redistributions of source code must retain the above copyright
109303f819SKyle Evans * notice, this list of conditions and the following disclaimer.
119303f819SKyle Evans * 2. Redistributions in binary form must reproduce the above copyright
129303f819SKyle Evans * notice, this list of conditions and the following disclaimer in the
139303f819SKyle Evans * documentation and/or other materials provided with the distribution.
149303f819SKyle Evans *
159303f819SKyle Evans * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
169303f819SKyle Evans * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
179303f819SKyle Evans * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
189303f819SKyle Evans * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
199303f819SKyle Evans * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
209303f819SKyle Evans * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
219303f819SKyle Evans * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
229303f819SKyle Evans * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
239303f819SKyle Evans * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
249303f819SKyle Evans * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
259303f819SKyle Evans * SUCH DAMAGE.
269303f819SKyle Evans *
279303f819SKyle Evans * Though this file is initially distributed under the 2-clause BSD license,
289303f819SKyle Evans * the author grants permission for its redistribution under alternative
299303f819SKyle Evans * licenses as set forth at <https://rhodiumtoad.github.io/RELICENSE.txt>.
309303f819SKyle Evans * This paragraph and the RELICENSE.txt file are not part of the license and
319303f819SKyle Evans * may be omitted in redistributions.
329303f819SKyle Evans */
339303f819SKyle Evans
349303f819SKyle Evans #include <stdio.h>
359303f819SKyle Evans #include <stdlib.h>
369303f819SKyle Evans #include <stdarg.h>
379303f819SKyle Evans #include <string.h>
389303f819SKyle Evans #include <unistd.h>
399303f819SKyle Evans #include <pthread.h>
409303f819SKyle Evans
410e907c04SKyle Evans void mod_main(int op);
420e907c04SKyle Evans
439303f819SKyle Evans static pthread_t thr;
449303f819SKyle Evans
459303f819SKyle Evans static void *
mod_thread(void * ptr __unused)460e907c04SKyle Evans mod_thread(void *ptr __unused)
479303f819SKyle Evans {
489303f819SKyle Evans char *volatile dummy;
499303f819SKyle Evans
509303f819SKyle Evans dummy = malloc(500);
51*a64a3b79SKonstantin Belousov *dummy = 'a';
529303f819SKyle Evans return (NULL);
539303f819SKyle Evans }
549303f819SKyle Evans
559303f819SKyle Evans void
mod_main(int op)569303f819SKyle Evans mod_main(int op)
579303f819SKyle Evans {
589303f819SKyle Evans int rc;
599303f819SKyle Evans
609303f819SKyle Evans switch (op) {
619303f819SKyle Evans case 1:
629303f819SKyle Evans rc = pthread_create(&thr, NULL, mod_thread, NULL);
639303f819SKyle Evans if (rc != 0)
649303f819SKyle Evans _exit(1);
659303f819SKyle Evans break;
669303f819SKyle Evans case 0:
679303f819SKyle Evans pthread_join(thr, NULL);
689303f819SKyle Evans break;
699303f819SKyle Evans }
709303f819SKyle Evans }
719303f819SKyle Evans
72